public ActionResult EditRGroup(RoleGroupModel model) { ViewData["Roles"] = roleService.GetRoles(); //验证 if (!ModelState.IsValid) { return(View(model)); } //获取权限 int[] roles = Array.ConvertAll(Request["Role"].Split(new string[] { ",", "false" }, StringSplitOptions.RemoveEmptyEntries), s => Convert.ToInt32(s)); int result = 0; //修改 if (model.RG_no != null) { result = RGroupService.UpdateRoleGroup(Convert.ToInt32(model.RG_no), model.RG_name, roles); } //新增 else { result = RGroupService.InsertGroup(model.RG_name, roles); } if (result != 0) { return(RedirectToAction("RoleGroupList")); } return(View(model)); }
public static AspNetRoleGroup ConvertToAspNetRoleGroup(this RoleGroupModel data) { return(new AspNetRoleGroup() { Id = data.id, Name = data.roleGroupName }); }
public async Task <IHttpActionResult> CreateRoleGroup(RoleGroupModel model) { var Id = Guid.NewGuid().ToString(); model.id = Id; return(Ok(await Task.Run(() => rm.CreateRoleGroup(model)))); }
public RoleGroupModel UpdateRoleGroup(RoleGroupModel model) { var script = string.Format("UPDATE [RoleGroup] SET RoleGroupName='{0}',Description = '{1}' WHERE Id ={2}", model.RoleGroupName, model.Description, model.Id); _dbConnector.ExecuteCommand(new SqlCommand(script)); DataStorageService.UpdateRoleGroupRole(model); return(model); }
public RoleGroupModel AddRoleGroup(RoleGroupModel model) { var script = string.Format("INSERT INTO [RoleGroup](RoleGroupName,Description) VALUES('{0}','{1}');SELECT @@IDENTITY;", model.RoleGroupName, model.Description); model.Id = _dbConnector.GetIntegerValue(new SqlCommand(script)); DataStorageService.AddRoleGroupRole(model); return(model); }
public RoleGroupModel GetRoleGroupRole(RoleGroupModel roleGroup) { var script = string.Format("SELECT Role.* FROM [RoleGroupRole] INNER JOIN Role ON RoleGroupRole.RoleId = Role.Id WHERE RoleGroupRole.RoleGroupId = {0}", roleGroup.Id); var ds = _dbConnector.ExecuteCommandsDataSet(new SqlCommand(script)); roleGroup.Roles = PopulateRole(ds); return(roleGroup); }
public ServiceResponse Create([FromBody] RoleGroupModel model) { if (ValidationService.DuplicateValidate(model)) { return(new ServiceResponse { Response = _roleGroup.Create(model) }); } return(new ServiceResponse { ErrorMessage = "该权限组已存在,请重新输入" }); }
public async Task <RoleGroupModel> CreateRoleGroup(RoleGroupModel model) { try { AspNetRoleGroup data = await Task.Run(() => ManageRole.InsertRoleGroup(model.ConvertToAspNetRoleGroup())); return(data.ConvertToRoleGroup()); } catch (Exception) { throw; } }
public bool InsertRoleGroup(RoleGroupModel model) { var sql = "INSERT INTO " + tableName + " (BRGRoleId,BRGGroupId,BRGIsValid) VALUES (@BRGRoleId,@BRGGroupId,@BRGIsValid)"; SqlParameter[] para = { new SqlParameter("@BRGRoleId", model.BRGRoleId), new SqlParameter("@BRGGroupId", model.BRGGroupId), new SqlParameter("@BRGIsValid", model.BRGIsValid) }; int cmdresult = Convert.ToInt32(ExecuteScalar(CommandType.Text, sql.ToString(), null, para)); return(cmdresult > 0); }
public RoleGroupModel AddRoleGroupRole(RoleGroupModel model) { var commands = new List <SqlCommand>(); foreach (var roleModel in model.Roles) { var script = string.Format("INSERT INTO [RoleGroupRole](RoleGroupId,RoleId) VALUES('{0}','{1}');", model.Id, roleModel.Id); commands.Add(new SqlCommand(script)); } _dbConnector.ExecuteCommands(commands); return(model); }
private IList <RoleGroupModel> PopulateRoleGroup(DataSet ds) { var models = new List <RoleGroupModel>(); if (ds != null) { foreach (DataRow rowItem in ds.Tables[0].Rows) { var model = new RoleGroupModel(); model.RoleGroupName = rowItem["RoleGroupName"].ToString(); model.Id = int.Parse(rowItem["Id"].ToString()); model.Description = rowItem["Description"].ToString(); model.DateCreated = DateTime.Parse(rowItem["DateCreated"].ToString()); model.DateUpdated = DateTime.Parse(rowItem["DateUpdated"].ToString()); model = DataStorageService.GetRoleGroupRole(model); models.Add(model); } } return(models); }
public static RoleGroupModel AddRoleGroup(RoleGroupModel model) { return(Provider.AddRoleGroup(model)); }
public static RoleGroupModel UpdateRoleGroup(RoleGroupModel model) { return(Provider.UpdateRoleGroup(model)); }
public static RoleGroupModel GetRoleGroupRole(RoleGroupModel roleGroup) { return(Provider.GetRoleGroupRole(roleGroup)); }