예제 #1
0
        public ActionResult <Users> AddUser(Users users)
        {
            var u = _user.AddUser(users);

            if (u != null)
            {
                return(Ok(u));
            }
            else
            {
                return(NotFound());
            }
        }
예제 #2
0
 /// <summary>
 /// 保存用户
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="userName"></param>
 /// <param name="mobile"></param>
 /// <param name="email"></param>
 /// <param name="realName"></param>
 /// <param name="isAdmin"></param>
 /// <returns></returns>
 public JsonResult SaveUser(string userId   = "", string userName = "", string mobile = "", string email = "",
                            string realName = "", int isAdmin     = 0)
 {
     try
     {
         userDb = new UserDb(CurrentUserConnectionInfo);
         var user = new UserModel();
         if (!string.IsNullOrWhiteSpace(userId))
         {
             user = userDb.GetUserById(userId);
             if (user == null)
             {
                 return(Json(new { result = 0, msg = "保存失败!找不到该用户信息!" }, JsonRequestBehavior.AllowGet));
             }
         }
         user.mobile           = mobile;
         user.email            = email;
         user.name             = realName;
         user.last_update_by   = CurrentUser.user_id;
         user.last_update_time = DateTime.Now;
         user.company_admin    = isAdmin;
         if (string.IsNullOrWhiteSpace(userId))
         {
             user.create_by    = CurrentUser.user_id;
             user.company_id   = CurrentCompany.company_id;
             user.create_time  = user.last_update_time;
             user.system_admin = 0;
             user.user_id      = Guid.NewGuid().ToString();
             user.username     = userName;
             user.password     = ("123456").GetMd5(2);
             userDb.AddUser(user);
         }
         else
         {
             userDb.UpdateUser(user);
         }
         return(Json(new { result = 1, msg = "保存成功" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(new { result = 0, msg = "保存失败" }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #3
0
파일: UserOperations.cs 프로젝트: DrFen/dnd
        public Response <Guid?> AddUser(LoginUserModel userModel)
        {
            if (userModel == null)
            {
                return new Response <Guid?>
                       {
                           Value        = null,
                           ErrorCode    = (int)ErrorEnum.Aplied,
                           ErrorMessage = "Пустой запрос"
                       }
            }
            ;

            var createResult = _userContext.AddUser(userModel.Login, userModel.Password);

            return(new Response <Guid?>
            {
                Value = createResult.id,
                ErrorCode = createResult.result == 1 ? (int)ErrorEnum.Ok : (int)ErrorEnum.Aplied,
                ErrorMessage = createResult.errormessage
            });
        }
예제 #4
0
 public string AddUser(Users user)
 {
     return(iUserDb.AddUser(user));
 }