public async Task <BaseResponse <UserViewModelResource> > UpdateUser(UserViewModelResource userViewModel, string userName) { Users user = await userManager.FindByNameAsync(userName); if (userManager.Users.Count(c => c.PhoneNumber == userViewModel.PhoneNumber) > 1) { return(new BaseResponse <UserViewModelResource>("Bu telefon numarası başka bri üyeye ait.")); } user.Name = userViewModel.Name; user.Surname = userViewModel.Surname; user.Email = userViewModel.Email; user.PhoneNumber = userViewModel.PhoneNumber; user.Photo = userViewModel.Photo; user.Address = userViewModel.Address; user.Gender = userViewModel.Gender; IdentityResult result = await userManager.UpdateAsync(user); if (result.Succeeded) { return(new BaseResponse <UserViewModelResource>(user.Adapt <UserViewModelResource>())); } else { return(new BaseResponse <UserViewModelResource>(result.Errors.First().Description)); } }
public async Task <BaseResponse <UserViewModelResource> > SignUp(UserViewModelResource userViewModel) { Users user = new Users { UserName = userViewModel.UserName, Email = userViewModel.Email }; IdentityResult result = await this.userManager.CreateAsync(user); if (result.Succeeded) { return(new BaseResponse <UserViewModelResource>(user.Adapt <UserViewModelResource>())); } else { return(new BaseResponse <UserViewModelResource>(result.Errors.First().Description)); } }
public async Task <ActionResult> GetUser() { Users user = await userService.GetUserByUserName(User.Identity.Name); return(Ok(user.Adapt <UserViewModelResource>())); }