Esempio n. 1
0
        public IActionResult Week()
        {
            var card = SessionExtensions.Get <Card>(HttpContext.Session, "Planning");

            if (card == null)
            {
                card = new Card();
            }
            return(View(card));
        }
Esempio n. 2
0
        public IActionResult Overview()
        {
            Card card = SessionExtensions.Get <Card>(HttpContext.Session, "Planning");

            if (card == null)
            {
                card = new Card();
            }
            return(View("Overview", card));
        }
Esempio n. 3
0
        private Card setCard()
        {
            var card = SessionExtensions.Get <Card>(HttpContext.Session, "Planning");

            if (card == null)
            {
                card = new Card();
            }

            return(card);
        }
Esempio n. 4
0
        public RedirectToActionResult SaveWeek(DateTime date)
        {
            var card = SessionExtensions.Get <Card>(HttpContext.Session, "Planning");

            if (card == null)
            {
                card = new Card();
            }
            card.PlanningForWeek = date;
            SessionExtensions.Set <Card>(HttpContext.Session, "Planning", card);

            return(RedirectToAction("Monday", _repository.Dishes));
        }
Esempio n. 5
0
        public ActionResult AddToPlanning(int DayNr, int DishId)
        {
            Dish dish = _repository.Dishes.FirstOrDefault(d => d.DishId == DishId);

            var card = SessionExtensions.Get <Card>(HttpContext.Session, "Planning");

            if (card == null)
            {
                card = new Card();
            }
            card.AddDish(DayNr, dish);
            SessionExtensions.Set <Card>(HttpContext.Session, "Planning", card);
            return(Redirect(HttpContext.Request.Headers["Referer"].ToString()));
        }
Esempio n. 6
0
        public RedirectToActionResult Save()
        {
            Card card = SessionExtensions.Get <Card>(HttpContext.Session, "Planning");

            if (card == null)
            {
                card = new Card();
            }

            DateTime PlanningForWeek = card.PlanningForWeek;

            if (_repository.Weekplannings.Any(w => w.Year == PlanningForWeek.Year && w.Week == (PlanningForWeek.DayOfYear / 7) + 1))
            {
                TempData["message"] = $"Er is al een planning voor week {(PlanningForWeek.DayOfYear / 7) + 1}";
                return(RedirectToAction("Overview"));
            }

            int currentYear = DateTime.Now.Year;
            int currentWeek = (DateTime.Now.DayOfYear / 7) + 1;

            if (currentYear <= card.PlanningForWeek.Year && currentWeek < (card.PlanningForWeek.DayOfYear / 7) + 1)
            {
                if (Check(card))
                {
                    _repository.savePlanning(card);
                    TempData["message"] = $"Planning is succesvol verstuurd voor gebruik in week {(card.PlanningForWeek.DayOfYear / 7) + 1}";
                    HttpContext.Session.Remove("Planning");
                }
                return(RedirectToAction("Overview"));
            }
            else
            {
                TempData["message"] = "Planning moet minimaal op zondag 23:59 de week van tevoren ingevuld worden";
                return(RedirectToAction("Overview"));
            }
        }