/// <summary> /// Gets and converts HIT information into view models. /// </summary> /// <returns></returns> private ObservableCollection <HitExpandViewModel> CreateHitExpands() { ObservableCollection <HitExpandViewModel> ret = new ObservableCollection <HitExpandViewModel>(); var allHITs = HitStructure.getHITs(); HitExpandViewModel currExpand = null; String prevDate = ""; for (int i = 0; i < allHITs.Count; i++) { String date = ((HitInfo)allHITs[i]).date; HitInfo hit = (HitInfo)allHITs[i]; HitInfoViewModel info = new HitInfoViewModel(hit.id, hit.date, hit.requester, hit.name, hit.amt, hit.bonus, hit.status); if (!prevDate.Equals(date)) { if (currExpand != null) { ret.Add(currExpand); } currExpand = new HitExpandViewModel(date, new ObservableCollection <HitInfoViewModel>()); currExpand.hitList.Add(info); prevDate = date; //adds to collection if this is the last iteration of loop if (i == allHITs.Count - 1) { ret.Add(currExpand); } } else { currExpand.hitList.Add(info); } currExpand.total += Double.Parse(hit.amt); currExpand.total += Double.Parse(hit.bonus); allTotal += Double.Parse(hit.amt); allTotal += Double.Parse(hit.bonus); if (hit.status.Equals(Status.Pending.ToString())) { currExpand.pending += Double.Parse(hit.amt); allPending += Double.Parse(hit.amt); } } return(ret); }
/// <summary> /// Opens an edit window for the selected object. /// </summary> public void edit() { Console.WriteLine(selected.id); HitInfoViewModel info = new HitInfoViewModel(selected.id, selected.date, selected.requester, selected.name, selected.amount, selected.bonus, "Pending"); EditWindow edit = new EditWindow(); edit.DataContext = info; if (edit.ShowDialog() == true) { GalaSoft.MvvmLight.Messaging.Messenger.Default.Send <String>("new"); } }