Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ticket
- {
- public int Id { get; set; }
- public int ScheduleId { get; set; }
- public int SeatId { get; set; }
- [DataType(DataType.Date)]
- [Column(TypeName = "Date")]
- [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
- public DateTime ForDate { get; set; }
- public Seat Seat { get; set; }
- public Schedule Schedule { get; set; }
- public ICollection<TicketStop> TicketStops { get; set; }
- }
- public class TicketStop
- {
- public int Id { get; set; }
- public int TicketId { get; set; }
- public int LineStopStationId { get; set; }
- public Ticket Ticket { get; set; }
- public LineStopStation LineStopStation { get; set; }
- }
- public class LineStopStation
- {
- public int Id { get; set; }
- public int LineId { get; set; }
- public int StopId { get; set; }
- public int Order { get; set; }
- public bool IsLastStop { get; set; }
- public Line Line { get; set; }
- public Stop Stop { get; set; }
- }
- int startStationOrder = _context.LineStopStations
- .First(l => l.LineId == lineId && l.StopId == startId).Order;
- int endStationOrder = _context.LineStopStations
- .First(l => l.LineId == lineId && l.StopId == endId).Order;
- public List<Seat> GetAvailableSeats(int lineId, int scheduleId, int startId, int endId, DateTime forDate)
- {
- int startStationOrder = _context.LineStopStations
- .First(l => l.LineId == lineId && l.StopId == startId).Order;
- int endStationOrder = _context.LineStopStations
- .First(l => l.LineId == lineId && l.StopId == endId).Order;
- var reservedSeats = _context.TicketStops
- .Where(t => t.Ticket.ScheduleId == scheduleId)
- .Where(t => t.Ticket.ForDate == forDate)
- //basically I don't know how to proceed here.
- //In pseudo code it should be something like:
- .Where(t => t.Min(Order) >= endStationOrder || t.Max(Order) <= startStationOrder
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement