private void ClickRecordMenuAction(string action, Record record) { //var dayRecord = DayRecords.Where(d => d.Date.DayOfWeek == record.Date.DayOfWeek).FirstOrDefault(); //var _record = dayRecord.Find(r => r.Id == record.Id); foreach (var dayRecord in DayRecords.ToList()) { foreach (var _record in dayRecord) { if (_record.Id == record.Id) { if (action == AppResources.Delete) { ConfirmDeletingRecord(record); RefreshRecordsBySearch(); } else { if (action == AppResources.Success && !_record.IsSuccess) { ConfirmChangingSuccessRecord(_record); } else if (action == AppResources.Failure && _record.IsSuccess) { _record.IsSuccess = false; App.AlarmsRepo.SaveRecord(_record); SendMessage("changeWeekRecord", WeekRecord); OnPropertyChanged(nameof(WeekSuccessRate)); SetDayRecords(); } else { return; } } } } } }
private void SetDayRecords() { var startDateOfSelectedWeek = SelectedWeek; var monList = new DayRecord() { DayOfWeek = AppResources.Monday, Date = startDateOfSelectedWeek }; var tueList = new DayRecord() { DayOfWeek = AppResources.Tuesday, Date = startDateOfSelectedWeek.AddDays(1) }; var wedList = new DayRecord() { DayOfWeek = AppResources.Wednesday, Date = startDateOfSelectedWeek.AddDays(2) }; var thuList = new DayRecord() { DayOfWeek = AppResources.Thursday, Date = startDateOfSelectedWeek.AddDays(3) }; var friList = new DayRecord() { DayOfWeek = AppResources.Friday, Date = startDateOfSelectedWeek.AddDays(4) }; var satList = new DayRecord() { DayOfWeek = AppResources.Saturday, Date = startDateOfSelectedWeek.AddDays(5) }; var sunList = new DayRecord() { DayOfWeek = AppResources.Sunday, Date = startDateOfSelectedWeek.AddDays(6) }; foreach (var record in WeekRecord.DayRecords) { switch (record.Date.DayOfWeek) { case DayOfWeek.Monday: monList.Add(record); break; case DayOfWeek.Tuesday: tueList.Add(record); break; case DayOfWeek.Wednesday: wedList.Add(record); break; case DayOfWeek.Thursday: thuList.Add(record); break; case DayOfWeek.Friday: friList.Add(record); break; case DayOfWeek.Saturday: satList.Add(record); break; case DayOfWeek.Sunday: sunList.Add(record); break; } } var dayRecordList = new ObservableCollection <DayRecord> { monList, tueList, wedList, thuList, friList, satList, sunList }; DayRecords.Clear(); foreach (var dayList in dayRecordList.ToList()) { if (dayList.Count != 0) { DayRecords.Add(dayList); } } RefreshRecordChart(); }