public EditPrivilegeModel InitializeEditPrivilegeModel(Guid? id) { var model = new EditPrivilegeModel(); model.Id = id; if (id.HasValue) { model.Privilege = _privilegeRepository.Find(id.Value); model.PrivilegeName = model.Privilege.Name; model.PrivilegeCode = model.Privilege.Code; model.PrivilegeDescription = model.Privilege.Description; } return model; }
public ActionResult EditPrivilegePost(EditPrivilegeModel model) { try { model.UnitId = new NpcContext().CurrentUser.Unit.Id; _privilegeAction.EditPrivilege(model); } catch (Exception exception) { return RedirectToMessage("保存权时出错:" + exception.Message); } return RedirectToMessage("权限保存成功!"); }
public void EditPrivilege(EditPrivilegeModel editPrivilegeModel) { var privilege = editPrivilegeModel.Id.HasValue ? _privilegeRepository.Find(editPrivilegeModel.Id.Value) : new Privilege(); //判断PrivilegeCode是否重得 if (_privilegeRepository.IsCodeRepeat(editPrivilegeModel.PrivilegeCode, editPrivilegeModel.Id)) throw new ApplicationException("权限编码已被使用,请更换其它编码"); privilege.Code = editPrivilegeModel.PrivilegeCode; privilege.Name = editPrivilegeModel.PrivilegeName; privilege.Description = editPrivilegeModel.PrivilegeDescription; _privilegeRepository.Save(privilege); }