public virtual async Task <FulfillmentSchedule> GetStoreScheduleAsync(GetStoreScheduleParam param) { if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException("scope"); } if (param.FulfillmentLocationId == null) { throw new ArgumentException("fulfillmentLocationId"); } var cacheKey = new CacheKey(CacheConfigurationCategoryNames.StoreSchedule) { Scope = param.Scope }; cacheKey.AppendKeyParts(param.FulfillmentLocationId.ToString()); var request = new GetScheduleRequest { ScopeId = param.Scope, FulfillmentLocationId = param.FulfillmentLocationId, ScheduleType = ScheduleType.OpeningHours }; return (await CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false)); }
public virtual async Task <StoreScheduleViewModel> GetStoreScheduleViewModelAsync(GetStoreScheduleParam param) { if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException("scope"); } if (param.CultureInfo == null) { throw new ArgumentNullException("cultureInfo"); } if (param.FulfillmentLocationId == null) { throw new ArgumentException("fulfillmentLocationId"); } var overtureSchedule = await StoreRepository.GetStoreScheduleAsync(param).ConfigureAwait(false); var model = ViewModelMapper.MapTo <StoreScheduleViewModel>(overtureSchedule, param.CultureInfo); var today = DateTime.Today; var now = DateTime.Now; var todayOpeningTimes = StoreScheduleProvider.GetOpeningTimes(overtureSchedule, today).ToList(); model.IsOpenNow = IsTimeInIntervals(now.TimeOfDay, todayOpeningTimes); model.TodayOpeningTimes = todayOpeningTimes.Select( openingTime => ViewModelMapper.MapTo <ScheduleIntervalViewModel>(openingTime, param.CultureInfo) ).ToList(); var exceptions = StoreScheduleProvider.GetOpeningHourExceptions(overtureSchedule, today, 1); model.OpeningHourExceptions = exceptions.Select(ex => ViewModelMapper.MapTo <DailyScheduleExceptionViewModel>(ex, param.CultureInfo)) .ToList(); return(model); }