Пример #1
0
        public bool SetRoleRights(string roleID, string SysRightsID, out string msg)
        {
            SqlParameter param = new SqlParameter("@RoleID", roleID);

            roleRightService.ExecuteSql("DELETE FROM dbo.SysRoleRight WHERE RoleID=@RoleID", out msg, param);
            if (!string.IsNullOrEmpty(SysRightsID))
            {
                SysRightsID.Split(',').ToList().ForEach(rightid =>
                {
                    if (!string.IsNullOrEmpty(rightid))
                    {
                        var roleRight = new SysRoleRight()
                        {
                            ID      = IdentityCreator.NextIdentity,
                            RightID = rightid,
                            RoleID  = roleID,
                        };
                        roleRightService.Add(roleRight);
                    }
                });
                return(roleRightService.SaveChanges(out msg) > 0);
            }
            else
            {
                return(true);
            }
        }
Пример #2
0
        public IHttpActionResult AddUser(UserViewModel vm)
        {
            if (ModelState.IsValid)
            {
                try {
                    Mapper.CreateMap <UserViewModel, ActivityRoleRight>();
                    var entity = Mapper.Map <ActivityRoleRight>(vm);
                    entity.CreatedBy   = RequestContext.Principal.Identity.Name;
                    entity.CreatedDate = DateTime.Now;
                    _Service.Add(entity);
                    return(Ok(true));
                } catch (SmartException ex) {
                    return(BadRequest(ex.Message));
                }
            }

            return(BadRequest(ModelState));
        }