示例#1
0
        public ActionResult Add()
        {
            RoleAddModel model = new RoleAddModel();

            if (TempData["HintMessage"] != null)
            {
                ViewData["HintMessage"] = TempData["HintMessage"];
            }
            if (TempData["InvalidModel"] != null && TempData["BrokenRules"] != null)
            {
                Role role = TempData["InvalidModel"] as Role;
                model.Role = role ?? null;
            }

            model.Roots = this.repository.FindRoots();

            return View(model);
        }
示例#2
0
        public ActionResult Create(RoleAddModel model)
        {
            if (model == null || model.Role == null)
            {
                throw new ArgumentNullException("the model for add is null ");
            }

            ReadOnlyCollection<BrokenRule> brokenRules = model.Role.GetBrokenRules();

            if (brokenRules.Count > 0)
            {
                TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,检测公司添加失败" };
                TempData["BrokenRules"] = brokenRules;
                TempData["InvalidModel"] = model;
            }
            this.repository.Add(model.Role);
            this.unitOfWork.Commit();
            return this.RedirectToAction("Edit", new { id = model.Role.Key });
        }