public ActionResult Edit(DiyGroupModel model, bool continueEditing) { var diyGroup = _diyService.GetDiyGroupById(model.Id); if (diyGroup == null || diyGroup.Deleted) //No category found with the specified id return RedirectToAction("List"); if (ModelState.IsValid) { diyGroup = model.ToEntity(diyGroup); diyGroup.UpdatedOnUtc = DateTime.UtcNow; _diyService.UpdateDiyGroup(diyGroup); //search engine name model.SeName = diyGroup.ValidateSeName(model.SeName, diyGroup.Name, true); _urlRecordService.SaveSlug(diyGroup, model.SeName, 0); //locales UpdateLocales(diyGroup, model); _diyService.UpdateDiyGroup(diyGroup); //activity log _customerActivityService.InsertActivity("EditDiyGroup", _localizationService.GetResource("ActivityLog.EditDiyGroup"), diyGroup.Name); SuccessNotification(_localizationService.GetResource("Toi.Plugin.Misc.Branches.DiyGroups.Updated")); return continueEditing ? RedirectToAction("Edit", new { id = diyGroup.Id }) : RedirectToAction("List"); } //If we got this far, something failed, redisplay form //parent diyGroups model.ParentGroups = new List<DropDownItem> { new DropDownItem { Text = "[None]", Value = "0" } }; if (model.ParentGroupId > 0) { var parentDiyGroup = _diyService.GetDiyGroupById(model.ParentGroupId); if (parentDiyGroup != null && !parentDiyGroup.Deleted) model.ParentGroups.Add(new DropDownItem { Text = parentDiyGroup.GetFormattedBreadCrumb(_diyService), Value = parentDiyGroup.Id.ToString() }); else model.ParentGroupId = 0; } return View(model); }
protected void UpdateLocales(DiyGroup diyGroup, DiyGroupModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(diyGroup, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(diyGroup, x => x.Description, localized.Description, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(diyGroup, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(diyGroup, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(diyGroup, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(diyGroup, x => x.SeName, localized.SeName, localized.LanguageId); } }
public ActionResult Create() { var model = new DiyGroupModel(); //parent diyGroups model.ParentGroups = new List<DropDownItem> { new DropDownItem { Text = "[None]", Value = "0" } }; //locales AddLocales(_languageService, model.Locales); return View(model); }