public ActionResult Info(VendorInfoModel model, HttpPostedFileBase uploadedFile) { if (!_workContext.CurrentCustomer.IsRegistered()) return new HttpUnauthorizedResult(); if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo) return RedirectToRoute("CustomerInfo"); Picture picture = null; var pictureSize = _mediaSettings.AvatarPictureSize; if (uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName)) { try { var contentType = uploadedFile.ContentType; var vendorPictureBinary = uploadedFile.GetPictureBits(); picture = _pictureService.InsertPicture(vendorPictureBinary, contentType, null); } catch (Exception) { ModelState.AddModelError("", _localizationService.GetResource("Account.VendorInfo.Picture.ErrorMessage")); } } var vendor = _workContext.CurrentVendor; var prevPicture = _pictureService.GetPictureById(vendor.PictureId); if (ModelState.IsValid) { var description = Core.Html.HtmlHelper.FormatText(model.Description, false, false, true, false, false, false); vendor.Name = model.Name; vendor.Email = model.Email; vendor.Description = description; if (picture != null) { vendor.PictureId = picture.Id; if (prevPicture != null) _pictureService.DeletePicture(prevPicture); } //update picture seo file name UpdatePictureSeoNames(vendor); _vendorService.UpdateVendor(vendor); //notifications if (_vendorSettings.NotifyStoreOwnerAboutVendorInformationChange) _workflowMessageService.SendVendorInformationChangeNotification(vendor, _localizationSettings.DefaultAdminLanguageId); return RedirectToAction("Info"); } //If we got this far, something failed, redisplay form model.PictureUrl = _pictureService.GetPictureUrl(prevPicture, pictureSize); return View(model); }
public ActionResult Info() { if (!_workContext.CurrentCustomer.IsRegistered()) return new HttpUnauthorizedResult(); if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo) return RedirectToRoute("CustomerInfo"); var vendor = _workContext.CurrentVendor; var picture = _pictureService.GetPictureById(vendor.PictureId); var pictureSize = _mediaSettings.AvatarPictureSize; var model = new VendorInfoModel { Description = vendor.Description, Email = vendor.Email, Name = vendor.Name, PictureUrl = picture != null ? _pictureService.GetPictureUrl(picture, pictureSize) : string.Empty }; return View(model); }