public IEnumerable <TicketStatusViewModel> GetAll()
 {
     return(_mapper.Map <IEnumerable <TicketStatusViewModel> >(_ticketStatusRepository.GetAll()));
 }
Exemplo n.º 2
0
        /// <summary>
        //  This Method will return the Booked ticket list.
        /// </summary>
        /// <param name="BookedTicketFilter">Class for ticket filtering.</param>
        /// <returns>this will return the booked ticket view model object</returns>
        public List <BookedTicketViewModel> BookedTicketList(BookedTicketFilter filter)
        {
            var ticketOrdersList = _ticketOrdersRepository.FindBy(x => x.loginAccountNo == filter.agentAccountNo && x.ticketStatus == filter.ticketStatus);
            var bookedTicketList = _bookedTicketsRepository.GetAll();
            var ticketStatus     = _ticketStatusRepository.GetAll();

            DateTime defaultDate = Convert.ToDateTime("01/01/1900");

            if (!ticketOrdersList.Any() || !bookedTicketList.Any() || !ticketStatus.Any())
            {
                return(null);
            }

            var ticketList = (from t in ticketOrdersList.ToList()
                              join b in bookedTicketList.ToList() on t.Id equals b.ticketOrderId
                              join s in ticketStatus.ToList() on t.ticketStatus equals s.Id
                              select new BookedTicketViewModel
            {
                Id = b.Id,
                ticketOrderId = t.Id,
                irctcTxnNumber = t.irctcTxnNumber,
                ticketNumber = b.ticketNumber,
                pnrNumber = b.pnrNumber,
                sourceStation = t.sourceStation,
                destStation = t.destStation,
                journeyDay = t.journeyDay,
                journeyMonth = t.journeyMonth,
                journeyYear = t.journeyYear,
                bookedOn = b.bookedOn,
                status = s.shortName
            }).AsQueryable();

            if (!string.IsNullOrEmpty(filter.pnr))
            {
                ticketList = ticketList.Where(x => x.pnrNumber == filter.pnr);
            }

            if (!string.IsNullOrEmpty(filter.fromStation))
            {
                ticketList = ticketList.Where(x => x.sourceStation == filter.fromStation);
            }

            if (!string.IsNullOrEmpty(filter.toStation))
            {
                ticketList = ticketList.Where(x => x.destStation == filter.toStation);
            }

            if (!string.IsNullOrEmpty(filter.ticketNumber))
            {
                ticketList = ticketList.Where(x => x.ticketNumber == filter.ticketNumber);
            }

            if (filter.dateOfJourney != defaultDate)
            {
                ticketList = ticketList.Where(x => x.journeyDay == filter.dateOfJourney.Day &&
                                              x.journeyMonth == filter.dateOfJourney.Month && x.journeyYear == filter.dateOfJourney.Year);
            }

            ticketList.Skip((filter.pageIndex - 1) * filter.pages)
            .Take(filter.pages);

            return(ticketList.ToList());
        }