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)
                );
        }
Exemplo n.º 2
0
 public async Task <UserViewModel> Get(Guid id) =>
 mapper.Map <UserViewModel>(await userReadRepository.GetById(id));
Exemplo n.º 3
0
 public async Task <Domain.Models.Entity.User> GetById(Guid id)
 => await _userReadRepository.GetById(id);