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)); }
public ResortController(WaitTimeContext context, ILogger <ResortController> logger) { _context = context; }
public WaitTimeController(WaitTimeContext context, ILogger <WaitTimeController> logger) { _context = context; }
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 }; }) }); }
public LiftsController(WaitTimeContext context, ILogger <LiftsController> logger) { _context = context ?? throw new ArgumentNullException(nameof(context)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }