Esempio n. 1
0
        public IActionResult UpdateMealHour(int id)
        {
            var mealhourVm = _context.MealHour.AsNoTracking()
                             .Where(t => t.MealHourId == id).FirstOrDefault();
            MealHourVm m = new MealHourVm()
            {
                MealHourId    = mealhourVm.MealHourId,
                MealHourTitle = mealhourVm.MealHourTitle
            };

            return(View(m));
        }
Esempio n. 2
0
        public IActionResult MealHourInfo()
        {
            var s = _context.MealHour.AsNoTracking().ToList();
            var a = new List <MealHourVm>();
            int c = 1;

            foreach (var item in s)
            {
                MealHourVm sp = new MealHourVm()
                {
                    Serial        = c,
                    MealHourId    = item.MealHourId,
                    MealHourTitle = item.MealHourTitle
                };
                a.Add(sp);
                c++;
            }

            return(View(a));
        }
Esempio n. 3
0
        public IActionResult SetMealHour(MealHourVm mealHourVm)
        {
            var valid = _context.MealHour.AsNoTracking().
                        Where(t => t.MealHourTitle == mealHourVm.MealHourTitle).FirstOrDefault();

            if (valid != null)
            {
                ViewBag.Validation = "You have already added " + mealHourVm.MealHourTitle + ".";
                return(View());
            }
            MealHour m = new MealHour()
            {
                MealHourId    = 0,
                MealHourTitle = mealHourVm.MealHourTitle
            };

            _context.MealHour.Add(m);
            _context.SaveChanges();
            ViewBag.Success = "You have succesfully added " + mealHourVm.MealHourTitle + ".";
            ModelState.Clear();
            return(View());
        }
Esempio n. 4
0
        public IActionResult UpdateMealHour(MealHourVm mealHourVm)
        {
            var valid = _context.MealHour.AsNoTracking().
                        Where(t => t.MealHourTitle == mealHourVm.MealHourTitle).FirstOrDefault();

            if (valid != null)
            {
                ViewBag.Validation = "You have already added.";
                return(View());
            }
            MealHour m = new MealHour()
            {
                MealHourId    = mealHourVm.MealHourId,
                MealHourTitle = mealHourVm.MealHourTitle
            };

            _context.MealHour.Update(m);
            _context.SaveChanges();
            ModelState.Clear();
            //ViewBag.Success = "You have succesfully updated.";
            return(RedirectToAction("MealHourInfo"));
        }