public bool Update(VM.RoleInfoItem model, List <ModulePermission> ModulePermissions) { MD.tbl_Common_Role mdRoleModel = Ctx.tbl_Common_Role.First(u => u.RoleId == model.RoleId); mdRoleModel.Name = model.Name; mdRoleModel.Description = model.Description; mdRoleModel.UpdatedBy = model.UpdatedBy; mdRoleModel.UpdatedDate = DateTime.Now; UpdatePermission(ConvertToRolePermission(mdRoleModel.RoleId, model.UpdatedBy, ModulePermissions)); Ctx.SaveChanges(); return(true); }
public bool Create(VM.RoleInfoItem model, List <MVC2015.Web.Model.SystemMaint.Module.ModulePermission> ModulePermissions) { MD.tbl_Common_Role mdRoleModel = new MD.tbl_Common_Role(); mdRoleModel.Name = model.Name; mdRoleModel.Description = model.Description; mdRoleModel.CreatedBy = model.CreatedBy; mdRoleModel.CreatedDate = DateTime.Now; Ctx.tbl_Common_Role.Add(mdRoleModel); Ctx.SaveChanges(); //添加角色权限列表 CreatePermission(ConvertToRolePermission(mdRoleModel.RoleId, model.CreatedBy, ModulePermissions)); Ctx.SaveChanges(); return(true); }
public ActionResult Create(VM.RoleInfoItem model, List <ModulePermission> ModulePermissions) { BL.RoleInfo empBL = new BL.RoleInfo(); if (empBL.ValidateName(-1, model.Name)) { return(Content(ResourceHelper.GetValue("SMM_RoleInfo_NameExists"))); } if (empBL.ValidateModulePermissions(ModulePermissions)) { return(Content(ResourceHelper.GetValue("SMM_RoleInfo_AddPermissions"))); } model.CreatedBy = UserHelper.GetCurrentUser().LogonName; empBL.Create(model, ModulePermissions); //CacheDependencyHelper.Change(new string[] { BasicParam.RolePermissionCacheKey }); return(Content("Success")); }
public ActionResult Edit(VM.RoleInfoItem model, List <ModulePermission> ModulePermissions, string allSelectList, int currRoleId, string deleteUserIds) { BL.RoleInfo empBL = new BL.RoleInfo(); BL.UserInfo userBL = new BL.UserInfo(); if (empBL.ValidateName(model.RoleId, model.Name)) { return(Content(ResourceHelper.GetValue("SMM_RoleInfo_NameExists"))); } if (empBL.ValidateModulePermissions(ModulePermissions)) { return(Content(ResourceHelper.GetValue("SMM_RoleInfo_AddPermissions"))); } //empBL.e(model); model.UpdatedBy = UserHelper.GetCurrentUser().LogonName; empBL.Update(model, ModulePermissions); userBL.UpdateUserRole(allSelectList, currRoleId, deleteUserIds, model.UpdatedBy); //CacheDependencyHelper.Change(new string[] { BasicParam.RolePermissionCacheKey }); return(Content("Success")); }
// GET: SystemMaint/Role/Create public ActionResult Create() { ViewBag.ShowSubmit = true; VM.RoleInfoItem model = new VM.RoleInfoItem(); return(View(model)); }