Esempio n. 1
0
        public async Task <OperationResult> UpdateAsync(Guid id, Address address)
        {
            var addressToUpdate = await _addressesRepository.FindAsync(id);

            addressToUpdate.Update(address);

            var validationResult = _validator.Validate(addressToUpdate);

            if (!validationResult.IsValid)
            {
                var errors = validationResult.Errors.Select(e => e.ErrorMessage).ToList();
                return(new OperationResult(false, address, errors));
            }

            await _addressesRepository.UpdateAsync(addressToUpdate);

            await _unitOfWork.CommitAsync();

            return(new OperationResult(true, addressToUpdate, null));
        }