Example #1
0
        public async Task <ActionResult> PostTicketReservation(TicketReservationDTO ticketReservationDTO)
        {
            if (ticketReservationDTO == null)
            {
                return(BadRequest());
            }
            TicketReservation ticketReservation = new TicketReservation();

            ticketReservation.TicketNo         = ticketReservationDTO.TicketNo;
            ticketReservation.PassengerName    = ticketReservationDTO.PassengerName;
            ticketReservation.PassengerPhoneNo = ticketReservationDTO.PassengerPhoneNo;
            ticketReservation.PassengerEmail   = ticketReservationDTO.PassengerEmail;
            ticketReservation.Gender           = ticketReservationDTO.Gender;
            ticketReservation.NoOfTicket       = ticketReservationDTO.NoOfTicket;
            ticketReservation.UnitPrice        = ticketReservationDTO.UnitPrice;
            ticketReservation.SeatNo           = ticketReservationDTO.SeatNo;
            ticketReservation.ReservationDate  = ticketReservationDTO.ReservationDate;
            ticketReservation.RouteDetailID    = ticketReservationDTO.RouteDetailID;
            _unitOfWork.TicketReservation.Add(ticketReservation);
            await _unitOfWork.Complete();

            Payment payment = new Payment();

            payment.TicketResrvID = ticketReservation.TicketResrvID;
            payment.VendorName    = ticketReservationDTO.VendorName;
            payment.PaymentAmount = ticketReservationDTO.PaymentAmount;
            payment.TransactionID = ticketReservationDTO.TransactionID;
            payment.PaymentDate   = ticketReservationDTO.PaymentDate;
            _unitOfWork.Payment.Add(payment);
            await _unitOfWork.Complete();

            StringBuilder sb = new StringBuilder("", 200);

            _passangerPhoneNumber = ticketReservation.PassengerPhoneNo;
            sb.Append("Please Confirm Your Payment!!\n");
            sb.AppendLine("Your Ticket No: " + ticketReservation.TicketNo + "\n");
            sb.AppendLine("Your Journey Date : " + ticketReservation.ReservationDate.Date + "\n");

            sb.AppendLine("Your Seat No : " + ticketReservation.SeatNo.ToString() + "\n");
            sb.AppendLine("Thank Your for using our service\n");
            SendOneToOneSingleSms(ticketReservation.PassengerPhoneNo, sb.ToString());

            return(Ok(ticketReservation));
        }
        public async Task <IHttpActionResult> PostTicketReservation(TicketReservationDTO ticketReservationDTO)
        {
            if (ticketReservationDTO == null)
            {
                return(BadRequest());
            }
            TicketReservation ticketReservation = new TicketReservation();

            ticketReservation.TicketNo         = ticketReservationDTO.TicketNo;
            ticketReservation.PassengerName    = ticketReservationDTO.PassengerName;
            ticketReservation.PassengerPhoneNo = ticketReservationDTO.PassengerPhoneNo;
            ticketReservation.PassengerEmail   = ticketReservationDTO.PassengerEmail;
            ticketReservation.Gender           = ticketReservationDTO.Gender;
            ticketReservation.NoOfTicket       = ticketReservationDTO.NoOfTicket;
            ticketReservation.UnitPrice        = ticketReservationDTO.UnitPrice;
            ticketReservation.SeatNo           = ticketReservationDTO.SeatNo;
            ticketReservation.ReservationDate  = ticketReservationDTO.ReservationDate;
            ticketReservation.RouteDetailID    = ticketReservationDTO.RouteDetailID;
            _unitOfWork.TicketReservation.Add(ticketReservation);
            await _unitOfWork.Complete();

            Payment payment = new Payment();

            payment.TicketResrvID = ticketReservation.TicketResrvID;
            payment.VendorName    = ticketReservationDTO.VendorName;
            payment.PaymentAmount = ticketReservationDTO.PaymentAmount;
            payment.TransactionID = ticketReservationDTO.TransactionID;
            payment.PaymentDate   = ticketReservationDTO.PaymentDate;
            _unitOfWork.Payment.Add(payment);
            await _unitOfWork.Complete();

            SendOneToOneSingleSms(ticketReservation.PassengerPhoneNo, "Success");


            return(Ok(ticketReservation));
        }