private async void GetTimesheets() { var currentDate = DateTime.Now; var previousDate = currentDate.AddDays(-7); var nextDate = currentDate.AddDays(7); var startsAt = previousDate.Year + "-" + previousDate.Month + "-" + previousDate.Day; var endsAt = nextDate.Year + "-" + nextDate.Month + "-" + nextDate.Day; var url = String.Format("http://cannedair-staging.cfapps.io/v1/users/{0}/timesheets?starts_at={1}&ends_at={2}", CurrentUser.Instance.OpenAirId, "2013-11-18", "2013-12-25"); //startsAt, endsAt); TODO: Fix! IsLoading = true; var response = await _mainservice.GetTimesheets(url); var tmpList = new List<Timesheet>(); if (!String.IsNullOrEmpty(response)) { var responseJsonArray = JArray.Parse(response); foreach (var timesheet in responseJsonArray) { if (tmpList.Count == 3) { break; } tmpList.Add(JsonConvert.DeserializeObject<Timesheet>(timesheet.ToString())); } while (tmpList.Count < 3) { var emptyTimesheet = new Timesheet {UserId = String.Empty, Id = String.Empty, StartsAt = String.Empty, EndsAt = String.Empty, Tasks = new List<Task>()}; tmpList.Add(emptyTimesheet); } Timesheets = tmpList; } else { // TODO: failure } IsLoading = false; }
public List<Day> ValueList { get; set; } // public TimesheetWeek(Timesheet timesheet) { InitializeDaysDictionary(); OriginalTimesheet = timesheet; KeyList = new List<string>(); // ValueList = new List<Day>(); // foreach (var task in timesheet.Tasks) { var day = Convert.ToDateTime(task.Date).DayOfWeek.ToString().ToLower(); if (Days.ContainsKey(day)) { Days[day].TotalHours += Convert.ToDouble(task.Hours); Days[day].Tasks.Add(task); } } KeyList = Days.Keys.ToList(); // ValueList = Days.Values.ToList(); // }