public virtual async Task <IActionResult> Info(VendorInfoModel model, IFormFile uploadedFile) { if (!await _groupService.IsRegistered(_workContext.CurrentCustomer)) { return(Challenge()); } if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo) { return(RedirectToRoute("CustomerInfo")); } string pictureId = string.Empty; string contentType = string.Empty; byte[] vendorPictureBinary = null; if (uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName)) { try { contentType = uploadedFile.ContentType; if (string.IsNullOrEmpty(contentType)) { ModelState.AddModelError("", "Empty content type"); } else if (!contentType.StartsWith("image")) { ModelState.AddModelError("", "Only image content type is allowed"); } vendorPictureBinary = uploadedFile.GetPictureBits(); } catch (Exception) { ModelState.AddModelError("", _translationService.GetResource("Account.VendorInfo.Picture.ErrorMessage")); } } var vendor = _workContext.CurrentVendor; var prevPicture = await _pictureService.GetPictureById(vendor.PictureId); if (prevPicture == null) { vendor.PictureId = ""; } if (ModelState.IsValid && ModelState.ErrorCount == 0) { var description = FormatText.ConvertText(model.Description); vendor.Name = model.Name; vendor.Email = model.Email; vendor.Description = description; if (vendorPictureBinary != null && !string.IsNullOrEmpty(contentType)) { var picture = await _pictureService.InsertPicture(vendorPictureBinary, contentType, null, reference : Reference.Vendor, objectId : vendor.Id); if (picture != null) { vendor.PictureId = picture.Id; } } if (prevPicture != null) { await _pictureService.DeletePicture(prevPicture); } //update picture seo file name await UpdatePictureSeoNames(vendor); model.Address.ToEntity(vendor.Address, true); await _vendorService.UpdateVendor(vendor); //notifications if (_vendorSettings.NotifyStoreOwnerAboutVendorInformationChange) { await _messageProviderService.SendVendorInformationChangeMessage(vendor, _workContext.CurrentStore, _languageSettings.DefaultAdminLanguageId); } return(RedirectToAction("Info")); } var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id); model.Address = await _mediator.Send(new GetVendorAddress() { Language = _workContext.WorkingLanguage, Model = model.Address, Address = vendor.Address, ExcludeProperties = false, LoadCountries = () => countries, }); return(View(model)); }