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