public ActionResult AddHelpCategory() { HelpCategoryModel model = new HelpCategoryModel(); ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
public ActionResult EditHelpCategory(HelpCategoryModel model, int id = -1) { HelpInfo helpInfo = AdminHelps.GetHelpById(id); if (helpInfo == null) { return(PromptView("帮助分类不存在")); } if (ModelState.IsValid) { helpInfo.Pid = 0; helpInfo.Title = model.HelpCategoryTitle; helpInfo.Url = ""; helpInfo.Description = ""; helpInfo.DisplayOrder = model.DisplayOrder; AdminHelps.UpdateHelp(helpInfo); AddMallAdminLog("修改帮助分类", "修改帮助分类,帮助分类ID为:" + id); return(PromptView("帮助分类修改成功")); } ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
public ActionResult Create(HelpCategoryModel model) { if (ModelState.IsValid) { var now = DateTime.Now; try { var helpsCategory = model.ToEntity(); helpsCategory.Name = model.Name; helpsCategory.ParentId = model.ParentId; helpsCategory.Alias = Util.GetSEOAlias(model.Name); helpsCategory.Description = model.Description; helpsCategory.Created = now; helpsCategory.Modified = now; helpsCategory.OrderNumber = model.OrderNumber; helpsCategory.Status = model.Status; helpsCategory.Image = ""; helpsCategory.DefaultAdImage = ""; _helpCategoryService.AddHelpCategory(helpsCategory); return(RedirectToAction("Index")); } catch (Exception e) { ErrorNotification(e.ToString()); } } else { AddModelStateErrors(); } model.CategoryList = new SelectList(_helpCategoryService.Help_Categories_SelectTreeAll(), "Id", "Name", model.ParentId); model.ListStatus = new SelectList(new[] { new SelectListItem { Text = "Hiển thị", Value = HelpCategoryStatusConst.Active.ToString() }, new SelectListItem { Text = "Ẩn", Value = HelpCategoryStatusConst.InActive.ToString() } }, "Value", "Text", model.Status); Title = "Thêm mới danh mục"; ViewData["ToolbarTitle"] = Title; return(View(model)); }
public ActionResult EditHelpCategory(int id = -1) { HelpInfo helpInfo = AdminHelps.GetHelpById(id); if (helpInfo == null) { return(PromptView("帮助分类不存在")); } HelpCategoryModel model = new HelpCategoryModel(); model.HelpCategoryTitle = helpInfo.Title; model.DisplayOrder = helpInfo.DisplayOrder; ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
public ActionResult AddHelpCategory(HelpCategoryModel model) { if (ModelState.IsValid) { HelpInfo helpInfo = new HelpInfo() { Pid = 0, Title = model.HelpCategoryTitle, Url = "", Description = "", DisplayOrder = model.DisplayOrder }; AdminHelps.CreateHelp(helpInfo); AddMallAdminLog("添加帮助分类", "添加帮助分类,帮助分类为:" + model.HelpCategoryTitle); return(PromptView("帮助分类添加成功")); } ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
// // GET: /Admin/Categories/Create public ActionResult Create() { Title = "Thêm mới danh mục"; ViewData["ToolbarTitle"] = Title; var model = new HelpCategoryModel() { Status = HelpCategoryStatusConst.Active, CategoryList = new SelectList(_helpCategoryService.Help_Categories_SelectTreeAll(), "Id", "Name") }; model.ListStatus = new SelectList(new[] { new SelectListItem { Text = "Hiển thị", Value = HelpCategoryStatusConst.Active.ToString() }, new SelectListItem { Text = "Ẩn", Value = HelpCategoryStatusConst.InActive.ToString() } }, "Value", "Text"); return(View(model)); }
public ActionResult Edit(HelpCategoryModel model) { string command = Request.Form["submit"].ToString(); switch (command) { case "Save": case "SaveAndContinueEdit": if (ModelState.IsValid) { var now = DateTime.Now; try { var category = _helpCategoryService.GetHelpCategoryById(model.Id); if (category == null) { ErrorNotification("Không tìm thấy trang tĩnh nào thỏa mãn"); return(RedirectToAction("Index")); } category.ParentId = model.ParentId; category.Name = model.Name; category.Alias = Util.GetSEOAlias(model.Name); category.Description = model.Description; category.Modified = now; category.OrderNumber = model.OrderNumber; category.Status = model.Status; _helpCategoryService.UpdateHelpCategory(category); SuccessNotification("Cập nhật thông tin thành công"); if (command == "SaveAndContinueEdit") { Title = "Chỉnh sửa danh mục hỗ trợ: " + category.Name; //return View(pageModel); } else { return(RedirectToAction("Index")); } } catch (Exception e) { Title = "Chỉnh sửa danh mục hỗ trợ"; ErrorNotification(e.ToString()); } } break; case "Delete": return(RedirectToAction("Delete", new { id = model.Id })); default: ErrorNotification("Không rõ phương thức submit dữ liệu"); return(RedirectToAction("Index")); } ViewData["ToolbarTitle"] = Title; var lstParentCategory = _helpCategoryService.Help_Categories_SelectTreeAll(); var currentCate = lstParentCategory.SingleOrDefault(c => c.Id == model.Id); if (currentCate != null) { lstParentCategory.Remove(currentCate); lstParentCategory.RemoveAll(c => c.Lineage.Contains("/" + currentCate.Id + "/")); } model.CategoryList = new SelectList(lstParentCategory, "Id", "Name", model.ParentId); return(View(model)); }