Beispiel #1
0
 // PUT api/User/5
 public ResultModel Put(int id, [FromBody] SaveUserModel saveUserModel)
 {
     try
     {
         ResultModel result  = new ResultModel();
         bool        hasUser = RepositoryFactory.UserRepository.HasUser(id);
         if (!hasUser)
         {
             return(new ResultModel(ResultEnum.FAILED, @"ยังไม่มี User นี้ในระบบ"));
         }
         else
         {
             string updateErrorString = string.Empty;
             bool   updateResult      = RepositoryFactory.UserRepository.UpdateUser(id, saveUserModel.Name, saveUserModel.LastName, saveUserModel.BirthDate, saveUserModel.PositionId, saveUserModel.StartDate, saveUserModel.SubdivisionId, saveUserModel.Enabled, out updateErrorString);
             if (updateResult)
             {
                 return(new ResultModel(ResultEnum.OK, string.Empty));
             }
             else
             {
                 return(new ResultModel(ResultEnum.FAILED, updateErrorString));
             }
         }
     }
     catch (Exception ex)
     {
         return(new ResultModel(ResultEnum.FAILED, ex.Message));
     }
 }
 public async Task<int> SaveUser(SaveUserModel model) {
     using (var _context = new DataBaseContext())
     {
         object[] parameters = new object[] { model.UserName, model.Password };
          return await _context.ExecuteNonQueryAsync("sp_SaveNewUser", parameters);
     }
 }
        public async Task <MessageModel <SaveUserModel> > SaveGrafanaUser(RegisterViewModel model)
        {
            var userModel = new SaveUserModel
            {
                Name     = model.Username,
                Email    = model.EmailAddress,
                Login    = model.Username,
                Password = model.Password
            };
            var response = await ApiClientFactory.Instance.SaveUser(userModel);

            return(response);
        }
        public async Task UpadateUserAsync(SaveUserModel model, Guid userId)
        {
            var updateModel = new UpdateUserModel
            {
                Id          = userId,
                Address     = model.Address,
                DisplayName = model.DisplayName,
                FirstName   = model.FirstName,
                LastName    = model.LastName
            };

            await _userManager.UpdateUserAsync(updateModel);
        }
        public async Task UpadateUserAsync(SaveUserModel model, Guid userId)
        {
            UpdateUserModel updateUserModel = new UpdateUserModel
            {
                Id                 = userId,
                FirstName          = model.FirstName,
                LastName           = model.LastName,
                GitHubProfileUrl   = model.GitHubProfileUrl,
                LinkedInProfileUrl = model.LinkedInProfileUrl,
                ProfileImageUrl    = model.ProfileImageUrl,
                TwitterProfileUrl  = model.TwitterProfileUrl
            };

            await _userManager.UpadateUserAsync(updateUserModel);
        }
        public static EditUserViewModel ToServiceModel(this SaveUserModel model)
        {
            var serviceModel = new EditUserViewModel
            {
                Version   = model.Version,
                FirstName = model.FirstName,
                LastName  = model.LastName,
                UserName  = model.UserName,
                Email     = model.Email,
                Image     = { ImageId = model.ImageId },
                Password  = model.Password,
                Roles     = model.Roles
            };

            return(serviceModel);
        }
Beispiel #7
0
        private static SaveUserModel MapModel(GetUserResponse response)
        {
            var model = new SaveUserModel
            {
                Version   = response.Data.Version,
                FirstName = response.Data.FirstName,
                LastName  = response.Data.LastName,
                UserName  = response.Data.UserName,
                Email     = response.Data.Email,
                ImageId   = response.Data.ImageId
            };

            if (response.Roles != null)
            {
                model.Roles = response.Roles.Select(r => r.Name).ToList();
            }

            return(model);
        }
Beispiel #8
0
 public ResultModel InsertUser([FromBody] SaveUserModel saveUserModel)
 {
     try
     {
         ResultModel result            = new ResultModel();
         string      insertErrorString = string.Empty;
         bool        insertResult      = RepositoryFactory.UserRepository.InsertUser(saveUserModel.Name, saveUserModel.LastName, saveUserModel.BirthDate, saveUserModel.PositionId, saveUserModel.StartDate, saveUserModel.SubdivisionId, saveUserModel.Enabled, out insertErrorString);
         if (insertResult)
         {
             return(new ResultModel(ResultEnum.OK, string.Empty));
         }
         else
         {
             return(new ResultModel(ResultEnum.FAILED, insertErrorString));
         }
     }
     catch (Exception ex)
     {
         return(new ResultModel(ResultEnum.FAILED, ex.Message));
     }
 }
        public async Task <IHttpActionResult> Post(SaveUserModel model)
        {
            var result = await Services.SaveUser(model);

            return(Ok(result));
        }
Beispiel #10
0
 public async Task UpdateUserInfo([FromBody] SaveUserModel model, Guid userId)
 {
     await _userComposerService.UpadateUserAsync(model, userId);
 }