public ActionResult Add() { UserRankModel model = new UserRankModel(); Load(); return(View(model)); }
public ActionResult Add(UserRankModel model) { if (AdminUserRanks.GetUserRidByTitle(model.UserRankTitle) > 0) { ModelState.AddModelError("UserRankTitle", "名称已经存在"); } if (ModelState.IsValid) { UserRankInfo userRankInfo = new UserRankInfo() { System = 0, Title = model.UserRankTitle, Avatar = model.Avatar ?? "", CreditsLower = model.CreditsLower, CreditsUpper = model.CreditsUpper, LimitDays = 0 }; AdminUserRanks.CreateUserRank(userRankInfo); AddMallAdminLog("添加会员等级", "添加会员等级,会员等级为:" + model.UserRankTitle); return(PromptView("会员等级添加成功")); } Load(); return(View(model)); }
public ActionResult Edit(int userRid = -1) { UserRankInfo userRankInfo = AdminUserRanks.GetUserRankById(userRid); if (userRankInfo == null) { return(PromptView("会员等级不存在")); } if (userRankInfo.System == 1) { return(PromptView("系统等级不能编辑")); } UserRankModel model = new UserRankModel(); model.UserRankTitle = userRankInfo.Title; model.Avatar = userRankInfo.Avatar; model.CreditsLower = userRankInfo.CreditsLower; model.CreditsUpper = userRankInfo.CreditsUpper; Load(); return(View(model)); }
public ActionResult Edit(UserRankModel model, int userRid = -1) { UserRankInfo userRankInfo = AdminUserRanks.GetUserRankById(userRid); if (userRankInfo == null) { return(PromptView("会员等级不存在")); } if (userRankInfo.System == 1) { return(PromptView("系统等级不能编辑")); } int userRid2 = AdminUserRanks.GetUserRidByTitle(model.UserRankTitle); if (userRid2 > 0 && userRid2 != userRid) { ModelState.AddModelError("UserRankTitle", "名称已经存在"); } if (ModelState.IsValid) { userRankInfo.Title = model.UserRankTitle; userRankInfo.Avatar = model.Avatar ?? ""; userRankInfo.CreditsLower = model.CreditsLower; userRankInfo.CreditsUpper = model.CreditsUpper; AdminUserRanks.UpdateUserRank(userRankInfo); AddMallAdminLog("修改会员等级", "修改会员等级,会员等级ID为:" + userRid); return(PromptView("会员等级修改成功")); } Load(); return(View(model)); }