public async Task Handle(UpdateUserCommand message) { var existingUser = await userReadRepository.GetById(message.Id); if (existingUser == null) { throw new Exception("User not exists."); } ; if (await userReadRepository.ExistUserByEmail(message.Id, message.Email)) { throw new Exception("User already exists with this email."); } await userWriteRepository.Update( Models.User.CreateToUpdate(message.Id, message.Name, message.Email, existingUser.Password) ); }
public async Task <UserViewModel> Get(Guid id) => mapper.Map <UserViewModel>(await userReadRepository.GetById(id));
public async Task <Domain.Models.Entity.User> GetById(Guid id) => await _userReadRepository.GetById(id);