Example #1
0
 public static TicketView ToDomainResponse(this TicketEntityView ticket)
 {
     if (ticket != null)
     {
         return(new TicketView
         {
             Id = ticket.TicketId,
             Price = ticket.Price,
             TrainNumber = ticket.TrainNumber,
             RailwayWagonNumber = ticket.RailwayWagonNumber,
             PlaceNumber = ticket.PlaceNumber,
             RouteName = ticket.RouteName,
             UserName = ticket.UserName,
             UserSurname = ticket.UserSurname,
             TicketNumber = ticket.TicketNumber
         });
     }
     else
     {
         return(null);
     }
 }
Example #2
0
        public TicketEntityView GetTicketEntityResponseById(int id)
        {
            var ticket = _context.Tickets
                         .Where(x => x.TicketId == id)
                         .Join(_context.Users,
                               a => a.UserId, b => b.UserId,
                               (a, b) => new
            {
                TicketId     = a.TicketId,
                UserName     = b.Name,
                UserSurname  = b.Surname,
                TicketNumber = a.TicketNumber,
                Price        = a.Price,
                TrainId      = a.TrainId,
                PlaceId      = a.PlaceId,
                WagonId      = a.RailwayWagonId,
                RouteId      = a.RouteId
            })
                         .Join(_context.Places,
                               a => a.PlaceId, b => b.PlaceId,
                               (a, b) => new
            {
                TicketId     = a.TicketId,
                UserName     = a.UserName,
                UserSurname  = a.UserSurname,
                TicketNumber = a.TicketNumber,
                Price        = a.Price,
                PlaceNumber  = b.Number,
                TrainId      = a.TrainId,
                WagonId      = a.WagonId,
                RouteId      = a.RouteId
            })
                         .Join(_context.Trains,
                               a => a.TrainId, b => b.TrainId,
                               (a, b) => new
            {
                TicketId     = a.TicketId,
                UserName     = a.UserName,
                UserSurname  = a.UserSurname,
                TicketNumber = a.TicketNumber,
                Price        = a.Price,
                PlaceNumber  = a.PlaceNumber,
                TrainNumber  = b.TrainNumber,
                WagonId      = a.WagonId,
                RouteId      = a.RouteId
            })
                         .Join(_context.Wagons,
                               a => a.WagonId, b => b.WagonId,
                               (a, b) => new
            {
                TicketId     = a.TicketId,
                UserName     = a.UserName,
                UserSurname  = a.UserSurname,
                TicketNumber = a.TicketNumber,
                Price        = a.Price,
                PlaceNumber  = a.PlaceNumber,
                TrainNumber  = a.TrainNumber,
                WagonNumber  = b.Number,
                RouteId      = a.RouteId
            })
                         .Join(_context.Routes,
                               a => a.RouteId, b => b.RouteId,
                               (a, b) => new
            {
                TicketId     = a.TicketId,
                UserName     = a.UserName,
                UserSurname  = a.UserSurname,
                TicketNumber = a.TicketNumber,
                Price        = a.Price,
                PlaceNumber  = a.PlaceNumber,
                TrainNumber  = a.TrainNumber,
                WagonNumber  = a.WagonNumber,
                RouteName    = b.Name
            });

            TicketEntityView ticketView = ticket.Select(
                x => new TicketEntityView
            {
                TicketId           = x.TicketId,
                UserName           = x.UserName,
                UserSurname        = x.UserSurname,
                TicketNumber       = x.TicketNumber,
                Price              = x.Price,
                PlaceNumber        = x.PlaceNumber,
                TrainNumber        = x.TrainNumber,
                RailwayWagonNumber = x.WagonNumber,
                RouteName          = x.RouteName
            }).SingleOrDefault();

            return(ticketView);
        }
Example #3
0
        public TicketView GetTicketResponse(int id)
        {
            TicketEntityView ticketEntity = _ticketRepository.GetTicketEntityResponseById(id);

            return(ticketEntity.ToDomainResponse());
        }