SHARE
TWEET

Untitled

a guest Jun 15th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Ticket
  2. {
  3.     public int Id { get; set; }
  4.     public int ScheduleId { get; set; }
  5.     public int SeatId { get; set; }
  6.  
  7.     [DataType(DataType.Date)]
  8.     [Column(TypeName = "Date")]
  9.     [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
  10.     public DateTime ForDate { get; set; }
  11.  
  12.     public Seat Seat { get; set; }
  13.     public Schedule Schedule { get; set; }
  14.     public ICollection<TicketStop> TicketStops { get; set; }
  15. }
  16.  
  17. public class TicketStop
  18. {
  19.     public int Id { get; set; }
  20.     public int TicketId { get; set; }
  21.     public int LineStopStationId { get; set; }
  22.  
  23.     public Ticket Ticket { get; set; }
  24.     public LineStopStation LineStopStation { get; set; }
  25. }
  26.  
  27. public class LineStopStation
  28. {
  29.     public int Id { get; set; }
  30.     public int LineId { get; set; }
  31.     public int StopId { get; set; }
  32.     public int Order { get; set; }
  33.     public bool IsLastStop { get; set; }
  34.  
  35.     public Line Line { get; set; }
  36.     public Stop Stop { get; set; }
  37. }
  38.      
  39. int startStationOrder = _context.LineStopStations
  40.             .First(l => l.LineId == lineId && l.StopId == startId).Order;
  41.  
  42.         int endStationOrder = _context.LineStopStations
  43.             .First(l => l.LineId == lineId && l.StopId == endId).Order;
  44.      
  45. public List<Seat> GetAvailableSeats(int lineId, int scheduleId, int startId, int endId, DateTime forDate)
  46.  {
  47.    int startStationOrder = _context.LineStopStations
  48.        .First(l => l.LineId == lineId && l.StopId == startId).Order;
  49.  
  50.    int endStationOrder = _context.LineStopStations
  51.        .First(l => l.LineId == lineId && l.StopId == endId).Order;
  52.  
  53.    var reservedSeats = _context.TicketStops
  54.        .Where(t => t.Ticket.ScheduleId == scheduleId)
  55.        .Where(t => t.Ticket.ForDate == forDate)
  56.        //basically I don't know how to proceed here.
  57.        //In pseudo code it should be something like:
  58.        .Where(t => t.Min(Order) >= endStationOrder || t.Max(Order) <= startStationOrder
  59.  
  60.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top