public IActionResult Edit(NewsletterCategoryModel model, bool continueEditing) { var newsletterCategory = _newsletterCategoryService.GetNewsletterCategoryById(model.Id); if (newsletterCategory == null) { return(RedirectToAction("List")); } if (ModelState.IsValid) { newsletterCategory = model.ToEntity(newsletterCategory); _newsletterCategoryService.UpdateNewsletterCategory(newsletterCategory); SuccessNotification(_localizationService.GetResource("Admin.Promotions.NewsletterCategory.Updated")); return(continueEditing ? RedirectToAction("Edit", new { id = newsletterCategory.Id }) : RedirectToAction("List")); } //Stores model.PrepareStoresMappingModel(newsletterCategory, true, _storeService); return(View(model)); }
public IActionResult Create(NewsletterCategoryModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageNewsletterSubscribers)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var newsletterCategory = model.ToEntity(); newsletterCategory.Locales = UpdateLocales(newsletterCategory, model); newsletterCategory.Stores = model.SelectedStoreIds != null?model.SelectedStoreIds.ToList() : new List <string>(); _newsletterCategoryService.InsertNewsletterCategory(newsletterCategory); SuccessNotification(_localizationService.GetResource("Admin.Promotions.NewsletterCategory.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = newsletterCategory.Id }) : RedirectToAction("List")); } //Stores PrepareStoresMappingModel(model, null, false); return(View(model)); }
protected virtual List <LocalizedProperty> UpdateLocales(NewsletterCategory newsletterCategory, NewsletterCategoryModel model) { List <LocalizedProperty> localized = new List <LocalizedProperty>(); foreach (var local in model.Locales) { localized.Add(new LocalizedProperty() { LanguageId = local.LanguageId, LocaleKey = "Name", LocaleValue = local.Name }); localized.Add(new LocalizedProperty() { LanguageId = local.LanguageId, LocaleKey = "Description", LocaleValue = local.Description }); } return(localized); }
public static NewsletterCategory ToEntity(this NewsletterCategoryModel model, NewsletterCategory destination) { return(model.MapTo(destination)); }
public static NewsletterCategory ToEntity(this NewsletterCategoryModel model) { return(model.MapTo <NewsletterCategoryModel, NewsletterCategory>()); }