public Week Remove(Week week) { if (week.IsPersisted) { _repo.Delete(week); } return week; }
public void ShouldSetWeekToSelfWhenAddingUsage() { var week = new Week(); var usage = new HourUsage(); week.AddUsage(usage); Assert.That(week.Usages.Count, Is.EqualTo(1)); Assert.That(usage.Week, Is.EqualTo(week)); }
public Week NewWeek(DateTime maxDate) { maxDate = new List<DateTime> {maxDate, GetMaxStartDate()}.Max(); var startDate = _dateProvider.GetCurrentWeekStartDate(); while(startDate <= maxDate) { startDate = startDate.AddDays(7); } var week = new Week {StartDate = startDate}; return _repo.Save(week); }
public WeekViewModel(IWeekService weekService, IHourCodeProvider hourCodeProvider, Week week) { _weekService = weekService; Week = week; _hourCodeProvider = hourCodeProvider; Usages = new ObservableCollection<HourUsageViewModel>(); foreach (var hourUsage in Week.Usages) { Usages.Add(new HourUsageViewModel(_hourCodeProvider, this, hourUsage)); } SaveWeekCommand = new DelegateCommand(SaveWeek); AddUsageCommand = new DelegateCommand(AddUsage); }
public Week Save(Week week) { return _repo.Save(week); }