Exemplo n.º 1
0
        public async Task <IResult> AddAsync(PaymentAddDto paymentAddDto)
        {
            var rulesResult = BusinessRules.Run(await this.CheckIfPaymentHasBeenMadeByRentalId(paymentAddDto.RentalId));

            if (!rulesResult.Success)
            {
                return(rulesResult);
            }

            Payment paymentToAdd = new Payment()
            {
                RentalId  = int.Parse(paymentAddDto.RentalId),
                MoneyPaid = paymentAddDto.MoneyPaid
            };

            var addResult = await _paymentDal.AddAsync(paymentToAdd);

            if (!addResult)
            {
                return(new ErrorResult(Messages.PaymentCancelled));
            }

            return(new SuccessResult(Messages.PaymentSuccessful));
        }
Exemplo n.º 2
0
        public async Task <IDataResult <int> > GetByIdAdd(Payment payment)
        {
            await _paymentDal.AddAsync(payment);

            return(new SuccessDataResult <int>(payment.Id, Messages.PaymentAdded));
        }