public static FacebookHoursFormatted FormatFacebookHoursDay(FacebookHoursBox obj, DayOfWeek? day = null) { var dayTest = day ?? DateTimeOffset.Now.DayOfWeek; var toReturn = new FacebookHoursFormatted() { Day = dayTest }; switch (dayTest) { case DayOfWeek.Monday: toReturn.StartTime = obj.Hours.Mon1Open; toReturn.EndTime = obj.Hours.Mon1Close; return toReturn; case DayOfWeek.Tuesday: toReturn.StartTime = obj.Hours.Tue1Open; toReturn.EndTime = obj.Hours.Tue1Close; return toReturn; case DayOfWeek.Wednesday: toReturn.StartTime = obj.Hours.Wed1Open; toReturn.EndTime = obj.Hours.Wed1Close; return toReturn; case DayOfWeek.Thursday: toReturn.StartTime = obj.Hours.Thu1Open; toReturn.EndTime = obj.Hours.Thu1Close; return toReturn; case DayOfWeek.Friday: toReturn.StartTime = obj.Hours.Fri1Open; toReturn.EndTime = obj.Hours.Fri1Close; return toReturn; case DayOfWeek.Saturday: toReturn.StartTime = obj.Hours.Sat1Open; toReturn.EndTime = obj.Hours.Sat1Close; return toReturn; case DayOfWeek.Sunday: toReturn.StartTime = obj.Hours.Sun1Open; toReturn.EndTime = obj.Hours.Sun1Close; return toReturn; default: throw new InvalidEnumArgumentException(); } }
public void Execute() { using (var client = new HttpClient()) { var url = FacebookHelper.GenerateGetHoursPlaceRequest(Args.AccessToken, Args.FacebookId); var task = client.GetStringAsync(url); task.Wait(); var result = task.Result; var fbHours = JsonConvert.DeserializeObject<FacebookHoursBox>(result); if (fbHours != null && fbHours.Hours != null) { var hours = fbHours.Hours; Results = FormatHelper.FormatFacebookHoursDay(fbHours); } } }