Пример #1
0
        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));
        }
Пример #2
0
 public static AspNetRoleGroup ConvertToAspNetRoleGroup(this RoleGroupModel data)
 {
     return(new AspNetRoleGroup()
     {
         Id = data.id,
         Name = data.roleGroupName
     });
 }
Пример #3
0
        public async Task <IHttpActionResult> CreateRoleGroup(RoleGroupModel model)
        {
            var Id = Guid.NewGuid().ToString();

            model.id = Id;

            return(Ok(await Task.Run(() => rm.CreateRoleGroup(model))));
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
 public ServiceResponse Create([FromBody] RoleGroupModel model)
 {
     if (ValidationService.DuplicateValidate(model))
     {
         return(new ServiceResponse {
             Response = _roleGroup.Create(model)
         });
     }
     return(new ServiceResponse {
         ErrorMessage = "该权限组已存在,请重新输入"
     });
 }
Пример #8
0
        public async Task <RoleGroupModel> CreateRoleGroup(RoleGroupModel model)
        {
            try
            {
                AspNetRoleGroup data = await Task.Run(() => ManageRole.InsertRoleGroup(model.ConvertToAspNetRoleGroup()));

                return(data.ConvertToRoleGroup());
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #9
0
        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);
        }
Пример #10
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);
        }
Пример #11
0
        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));
 }
Пример #14
0
 public static RoleGroupModel GetRoleGroupRole(RoleGroupModel roleGroup)
 {
     return(Provider.GetRoleGroupRole(roleGroup));
 }