Example #1
0
        public async Task <ResponseList <PaymentResponse> > GetPaymentByTransport(PaymentGetByTransportRequest request)
        {
            var transport = await _uow.Transports.FindAsync(new Guid(request.TransportId));

            if (transport == null)
            {
                return(new ResponseList <PaymentResponse>(ResponseStatus.BadRequest, null, ResponseMessagesConstans.NotFound));
            }

            var payments = await _uow.Payments.FindManyAsync();

            switch (transport.Type)
            {
            case TransportType.DeliveryPoint:
                var possiblePaymentTypes = new List <PaymentType>()
                {
                    PaymentType.CashOnPlace, PaymentType.PaymentOrder
                };
                payments = payments.Where(payment => possiblePaymentTypes.Contains(payment.Type)).ToList();
                break;

            case TransportType.HomeDelivery:
                var possiblePaymentTypes2 = new List <PaymentType>()
                {
                    PaymentType.CashOnDelivery, PaymentType.PaymentOrder
                };
                payments = payments.Where(payment => possiblePaymentTypes2.Contains(payment.Type)).ToList();
                break;

            case TransportType.PersonalDelivery:
                var possiblePaymentTypes3 = new List <PaymentType>()
                {
                    PaymentType.CashOnPlace, PaymentType.PaymentOrder
                };
                payments = payments.Where(payment => possiblePaymentTypes3.Contains(payment.Type)).ToList();
                break;

            case TransportType.PersonalPickup:
                var possiblePaymentTypes4 = new List <PaymentType>()
                {
                    PaymentType.CashOnPlace, PaymentType.PaymentOrder
                };
                payments = payments.Where(payment => possiblePaymentTypes4.Contains(payment.Type)).ToList();
                break;
            }

            var response = payments.Select(x => _mapService.MapPayment(x)).ToList();

            return(new ResponseList <PaymentResponse>(ResponseStatus.Ok, response));
        }
Example #2
0
        public async Task <IHttpActionResult> Search([FromUri] PaymentGetByTransportRequest request)
        {
            var response = await _paymentService.GetPaymentByTransport(request);

            return(new CreateResult(response));
        }