internal ShortUser(Api api, ShortUserModel model) { _api = api; Id = model.Id; DisplayName = model.DisplayName; AvatarImageUrl = model.AvatarImageUrl; HtmlUrl = model.HtmlUrl; }
public async Task <User> UpdateUserAsync(Guid id, ShortUserModel userModel) { var user = await GetAsync(id); user.Login = userModel.Login; user.PasswordHash = _hashProvider.CreateHash(userModel.Password); user.Name = userModel.Name; user.Surname = userModel.Surname; user.RoleId = userModel.RoleId; return(await UpdateAsync(user)); }
public async Task <User> AddUserAsync(ShortUserModel userModel) { if (await AnyAsync(a => a.Login == userModel.Login)) { throw new Exception("User exist"); } userModel.Password = _hashProvider.CreateHash(userModel.Password); var user = _mapper.Map <User>(userModel); return(await AddAsync(user)); }
public async Task <UserModel> Put([FromRoute] Guid id, [FromBody] ShortUserModel userModel) { return(_mapper.Map <UserModel>(await _userService.UpdateUserAsync(id, userModel))); }
public async Task <UserModel> Post([FromBody] ShortUserModel userModel) { return(_mapper.Map <UserModel>(await _userService.AddUserAsync(userModel))); }