Exemple #1
0
 internal ShortUser(Api api, ShortUserModel model)
 {
     _api           = api;
     Id             = model.Id;
     DisplayName    = model.DisplayName;
     AvatarImageUrl = model.AvatarImageUrl;
     HtmlUrl        = model.HtmlUrl;
 }
Exemple #2
0
        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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 public async Task <UserModel> Put([FromRoute] Guid id, [FromBody] ShortUserModel userModel)
 {
     return(_mapper.Map <UserModel>(await _userService.UpdateUserAsync(id, userModel)));
 }
Exemple #5
0
 public async Task <UserModel> Post([FromBody] ShortUserModel userModel)
 {
     return(_mapper.Map <UserModel>(await _userService.AddUserAsync(userModel)));
 }