Example #1
0
 public void OnResourceExecuting(ResourceExecutingContext context)
 {
     if (context.HttpContext.Request.Headers.ContainsKey(TIMEZONE_KEY))
     {
         if (UseByTimeZoneId)
         {
             _dateProvider.SetTimeZone((int)TimeZoneInfo.FindSystemTimeZoneById(
                                           context.HttpContext.Request.Headers[TIMEZONE_KEY])
                                       .BaseUtcOffset.TotalMinutes);
         }
         else
         {
             var time = 0;
             int.TryParse(context.HttpContext.Request.Headers[TIMEZONE_KEY], out time);
             _dateProvider.SetTimeZone(time);
         }
     }
 }