Ejemplo n.º 1
0
 public ProfilesController(WaitTimeContext context, IHttpContextAccessor httpContextAccessor, ILogger <ProfilesController> logger)
 {
     _context             = context ?? throw new ArgumentNullException(nameof(context));
     _httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Ejemplo n.º 2
0
 public ResortController(WaitTimeContext context, ILogger <ResortController> logger)
 {
     _context = context;
 }
Ejemplo n.º 3
0
 public WaitTimeController(WaitTimeContext context, ILogger <WaitTimeController> logger)
 {
     _context = context;
 }
Ejemplo n.º 4
0
        internal static WaitTimeDateModel GetWaitTimeDate(int resortID, DateTime date, WaitTimeContext context)
        {
            var uplifts = context.Uplifts
                          .Where(uplift => uplift.Lift.ResortID == resortID &&
                                 uplift.LocalDate == date)
                          .OrderBy(uplift => uplift.LocalDateTime)
                          .ToList();

            var upliftsByTimePeriod = uplifts
                                      .GroupBy(uplift => new
            {
                TimePeriod = (int)(uplift.LocalDateTime.TimeOfDay.TotalMinutes / 15),
                uplift.LiftID,
            })
                                      .Select(g => new
            {
                g.Key.TimePeriod,
                g.Key.LiftID,
                WaitSeconds = g.Average(uplift => uplift.WaitSeconds)
            })
                                      .GroupBy(uplift => uplift.TimePeriod)
                                      .OrderBy(uplift => uplift.Key)
                                      .ToList();

            if (upliftsByTimePeriod.Count == 0)
            {
                return(null);
            }

            List <WaitTimeModel> cumulativeUplifts = null;

            return(new WaitTimeDateModel
            {
                Date = date,
                TimePeriods = Enumerable
                              .Range(upliftsByTimePeriod.First().Key, upliftsByTimePeriod.Last().Key - upliftsByTimePeriod.First().Key + 1)
                              .Select(timePeriod =>
                {
                    var upliftsResult = cumulativeUplifts != null ?
                                        new List <WaitTimeModel>(cumulativeUplifts) :
                                        new List <WaitTimeModel>();

                    upliftsByTimePeriod.FirstOrDefault(t => t.Key == timePeriod)?.ToList().ForEach(uplift =>
                    {
                        var existingUplift = upliftsResult.FirstOrDefault(w => w.LiftID == uplift.LiftID);
                        if (existingUplift != null)
                        {
                            existingUplift.Seconds = (int)uplift.WaitSeconds;
                        }
                        else
                        {
                            upliftsResult.Add(new WaitTimeModel
                            {
                                LiftID = uplift.LiftID,
                                Seconds = (int)uplift.WaitSeconds
                            });
                        }
                    });
                    cumulativeUplifts = upliftsResult;
                    return new WaitTimePeriodModel
                    {
                        Timestamp = timePeriod * 15 * 60,
                        WaitTimes = upliftsResult
                    };
                })
            });
        }
Ejemplo n.º 5
0
 public LiftsController(WaitTimeContext context, ILogger <LiftsController> logger)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
     _logger  = logger ?? throw new ArgumentNullException(nameof(logger));
 }