public ActionResult Create(PDCPMS.Modules.Authority.Model.BlockAddModel model) { if (model == null || model.block == null) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "操作失败,系统发生了一个错误" }; return RedirectToAction("Add"); } Module domainmodel = new Module(model.block.Name, model.block.AddDate, model.block.Description, model.block.Status); ReadOnlyCollection<BrokenRule> brokenRules = domainmodel.GetBrokenRules(); if (brokenRules.Count != 0) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,模块添加失败" }; TempData["BrokenRules"] = brokenRules; TempData["InvalidModel"] = model; } repository.Add(domainmodel); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("模块({0})添加成功", model.block.Name) }; return RedirectToAction("Index"); }
public ActionResult Update(Module model) { if (model == null) { throw new HttpException(404, "无法找到指定的模块,请确认该模块是否存在"); } ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count != 0) { TempData["InvalidModel"] = model; TempData["BrokenRules"] = brokenRules; TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("模块({0})修改失败,请检查你的输入", model.Name) }; } else { repository[model.Key] = model; unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("模块({0})修改成功", model.Name) }; } return RedirectToAction("Index"); }