Skip to content

Commit

Permalink
#6168 Fixed bug when custom address fields are not saved for vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyKulagin committed Mar 14, 2022
1 parent 941f2af commit d6c06d8
Showing 1 changed file with 14 additions and 1 deletion.
Expand Up @@ -29,6 +29,7 @@ public partial class VendorController : BaseAdminController
{
#region Fields

private readonly IAddressAttributeParser _addressAttributeParser;
private readonly IAddressService _addressService;
private readonly ICustomerActivityService _customerActivityService;
private readonly ICustomerService _customerService;
Expand All @@ -48,7 +49,8 @@ public partial class VendorController : BaseAdminController

#region Ctor

public VendorController(IAddressService addressService,
public VendorController(IAddressAttributeParser addressAttributeParser,
IAddressService addressService,
ICustomerActivityService customerActivityService,
ICustomerService customerService,
IGenericAttributeService genericAttributeService,
Expand All @@ -63,6 +65,7 @@ public partial class VendorController : BaseAdminController
IVendorModelFactory vendorModelFactory,
IVendorService vendorService)
{
_addressAttributeParser = addressAttributeParser;
_addressService = addressService;
_customerActivityService = customerActivityService;
_customerService = customerService;
Expand Down Expand Up @@ -338,6 +341,14 @@ public virtual async Task<IActionResult> Edit(VendorModel model, bool continueEd
(await _vendorAttributeParser.GetAttributeWarningsAsync(vendorAttributesXml)).ToList()
.ForEach(warning => ModelState.AddModelError(string.Empty, warning));

//custom address attributes
var customAttributes = await _addressAttributeParser.ParseCustomAddressAttributesAsync(form);
var customAttributeWarnings = await _addressAttributeParser.GetAttributeWarningsAsync(customAttributes);
foreach (var error in customAttributeWarnings)
{
ModelState.AddModelError(string.Empty, error);
}

if (ModelState.IsValid)
{
var prevPictureId = vendor.PictureId;
Expand All @@ -360,6 +371,7 @@ public virtual async Task<IActionResult> Edit(VendorModel model, bool continueEd
if (address == null)
{
address = model.Address.ToEntity<Address>();
address.CustomAttributes = customAttributes;
address.CreatedOnUtc = DateTime.UtcNow;

//some validation
Expand All @@ -375,6 +387,7 @@ public virtual async Task<IActionResult> Edit(VendorModel model, bool continueEd
else
{
address = model.Address.ToEntity(address);
address.CustomAttributes = customAttributes;

//some validation
if (address.CountryId == 0)
Expand Down

0 comments on commit d6c06d8

Please sign in to comment.