public IActionResult Index() { CurrentWeek currentWeek = _currentWeekService.GetCurrentWeek(); if (currentWeek == null) { throw new Exception("currentWeek doesn't exist"); } if (!DoesDateLiesInCurrentWeek(currentWeek.Date)) { _ammountOfDoneDutiesArchiveRepository.ResetArchive(); var duties = _dutyRepository.Duties; foreach (var duty in duties) { var overdueDuty = new OverdueDuty() { Content = duty.Content, Category = duty.Category, CategoryId = duty.CategoryId }; _overdueDutyRepository.AddOverdueDuty(overdueDuty); _dutyRepository.RemoveDuty(duty); } currentWeek.Date = DateTime.Now; _dbContextService.Commit(); } var model = new IndexViewModel() { CurrentWeek = currentWeek, OverdueDuties = _overdueDutyRepository.OverdueDuties }; return(View(model)); }
public IActionResult RemoveDuty(string CategoryId, int DutyId) { var duty = _dutyRepository.GetDuty(DutyId); if (duty == null) { throw new Exception("No such duty"); } _dutyRepository.RemoveDuty(duty); _dbContextService.Commit(); return(RedirectToAction("Index", "Category", new { id = CategoryId })); }