Пример #1
0
        public async Task <OperationResult> AddAsync(PaymentMethod paymentMethod)
        {
            var validationResult = _validator.Validate(paymentMethod);

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

            await _paymentMethodsRepository.AddAsync(paymentMethod);

            await _unitOfWork.CommitAsync();

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