public async Task <Result> Handle(UpdateBusinessCommand command, CancellationToken cancellationToken) => await _repository.FetchUserAggregate(command.OwnerEmail) .FailureIf("User not found.") .Ensure(user => user.GetBusiness(command.Id) != null, "Business not found.") .AndThen(_ => _mapper.Map <Business>(command)) .Validate(_businessValidator) .Finally(updatedBusiness => _repository.UpdateEntity(command.Id, updatedBusiness));
public async Task <Result> Handle(UpdateUserInfoCommand command, CancellationToken cancellationToken) => await _repository.FetchUserAggregate(command.Id) .FailureIf("User not found.") .AndThen(user => user.Update(command.Name, command.Email, Convert(command))) .Validate(_validator) .Finally(updatedUser => _repository.UpdateEntity(updatedUser.Id, updatedUser));