Пример #1
0
        public IActionResult UserEdit(Sys_UserMapping SysUser, List <Guid> RoleIds)
        {
            if (!ModelState.IsValid)
            {
                return(NotValid());
            }
            (bool Status, string Message)res;
            var item = _mapper.Map <Entities.Sys_User>(SysUser);

            if (SysUser.Id != Guid.Empty)
            {
                res = _sysUserService.UpdateUser(SysUser, UserId);
            }
            else
            {
                item.Account      = item.Account.TrimSpace();
                item.Id           = CombGuid.NewGuid();
                item.CreationTime = DateTime.Now;
                item.Creator      = UserId;
                item.Salt         = EncryptorHelper.CreateSaltKey();
                item.Password     = (EncryptorHelper.GetMD5(item.Account + item.Salt));
                res = _sysUserService.AddUser(item);
            }
            AjaxData.Message = res.Message;
            AjaxData.Code    = res.Status ? 0 : 2001;
            if (res.Status)
            {
                _sysRoleService.SetUserRoles(item.Id, RoleIds, UserId);
            }
            return(Json(AjaxData));
        }
Пример #2
0
        public IActionResult UserEdit(Sys_UserMapping SysUser, List <string> RoleIds)
        {
            (bool Status, string Message)res;
            var item = _mapper.Map <Entities.sys_user>(SysUser);

            if (!String.IsNullOrEmpty(SysUser.id))
            {
                res = _sysUserService.UpdateUser(SysUser, UserId);
            }
            else
            {
                item.account       = item.account.TrimSpace();
                item.id            = CombGuid.NewGuidAsString();
                item.creation_time = DateTime.Now;
                item.creator       = UserId;
                item.salt          = EncryptorHelper.CreateSaltKey();
                item.password      = (EncryptorHelper.GetMD5(item.account + item.salt));
                res = _sysUserService.AddUser(item);
            }
            AjaxData.Message = res.Message;
            AjaxData.Success = res.Status;
            if (res.Status)
            {
                _sysRoleService.SetUserRoles(item.id, RoleIds, UserId);
            }
            return(Json(AjaxData));
        }
Пример #3
0
 public IActionResult OnPost(Guid id)
 {
     _sysRoleService.SetUserRoles(id, RoleIds, UserId);
     AjaxData.Code    = 0;
     AjaxData.Message = "保存成功";
     return(Json(AjaxData));
 }
Пример #4
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(NotValid());
            }
            (bool Status, string Message)res;
            var item = _mapper.Map <Entities.Sys_User>(SysUser);

            if (SysUser.Id != Guid.Empty)
            {
                res = _sysUserService.UpdateUser(SysUser, UserId);
            }
            else
            {
                item.Id           = CombGuid.NewGuid();
                item.CreationTime = DateTime.Now;
                item.Creator      = UserId;
                res = _sysUserService.AddUser(item);
            }
            AjaxData.Message = res.Message;
            AjaxData.Code    = res.Status ? 0 : 2001;
            if (res.Status)
            {
                _sysRoleService.SetUserRoles(item.Id, RoleIds, UserId);
            }
            return(Json(AjaxData));
        }
Пример #5
0
 public IActionResult OnGet(Guid id)
 {
     _sysUserService.Delete(id, UserId);
     try
     {
         _sysUserJwtService.CompelOut(id);
         _sysRoleService.SetUserRoles(id, null, UserId);
     }
     catch (Exception)
     {
     }
     AjaxData.Code    = 0;
     AjaxData.Message = "删除成功";
     return(Json(AjaxData));
 }