async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); DaysGroupings.Clear(); var items = await DataStore.GetItemsAsync(true); Items.ReplaceRange(items); SortItems(); } catch (Exception ex) { Debug.WriteLine(ex); MessagingCenter.Send(new MessagingCenterAlert { Title = "Error", Message = "Unable to load items.", Cancel = "OK" }, "message"); } finally { IsBusy = false; } }
private void SortItems() { foreach (var monthGrouping in Items.OrderByDescending(x => x.Date).GroupBy(x => x.Date.ToString("MMMM"))) { var dayGroup = new DayGroupList(); dayGroup.AddRange(monthGrouping); dayGroup.Heading = monthGrouping.Key.ToString(); DaysGroupings.Add(dayGroup); } }