示例#1
0
        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));
        }
示例#2
0
 public void RemoveOverdueDuty(OverdueDuty overdueDuty)
 {
     _context.OverdueDuties.Remove(overdueDuty);
 }
示例#3
0
 public void AddOverdueDuty(OverdueDuty overdueDuty)
 {
     _context.Add(overdueDuty);
 }