Exemple #1
0
        public async Task <IActionResult> Category(string beskrivning)
        {
            if (string.IsNullOrEmpty(beskrivning))
            {
                return(RedirectToAction("Index"));
            }

            // Try filter
            MatrattTyp typ = await dbContext.MatrattTyp
                             .FirstOrDefaultAsync(m =>
                                                  m.Beskrivning.IndexOf(beskrivning, StringComparison.CurrentCultureIgnoreCase) != -1);

            // Invalid filter?
            if (typ == null)
            {
                return(RedirectToAction("Index"));
            }

            // Filter items
            ViewData["Title"] = typ.Beskrivning;

            List <Matratt> matratts = await dbContext.Matratt
                                      .Include(m => m.MatrattTypNavigation)
                                      .Include(m => m.MatrattProdukt).ThenInclude(m => m.Produkt)
                                      .Where(m => typ == null || m.MatrattTyp == typ.MatrattTyp1)
                                      .ToListAsync();

            return(View("Index", matratts));
        }
Exemple #2
0
        public async Task <IActionResult> DeleteType(int typeId)
        {
            List <Matratt> check        = _repository.SelectMattrattByType(typeId);
            MatrattTyp     typeToDelete = await _repository.SelectById <MatrattTyp>(typeId);

            if (check.Count == 0)
            {
                await _repository.DeleteAsync <MatrattTyp>(typeToDelete);
            }
            else
            {
                MatrattTyp defaultType = _repository.GetDefaultType();

                foreach (var matratt in check)
                {
                    matratt.MatrattTyp = defaultType.MatrattTyp1;

                    await _repository.UpdateAsync <Matratt>(matratt);
                }

                await _repository.DeleteAsync <MatrattTyp>(typeToDelete);
            }

            return(RedirectToAction("DishTypes"));
        }
Exemple #3
0
        public async Task <IActionResult> UpdateDishType(MatrattTyp model)
        {
            MatrattTyp dishType = await _repository.SelectById <MatrattTyp>(model.MatrattTyp1);

            dishType.Beskrivning = model.Beskrivning;
            await _repository.UpdateAsync <MatrattTyp>(dishType);

            return(RedirectToAction("DishTypes"));
        }
Exemple #4
0
 public MenuPage()
 {
     matratt         = new Matratt();
     mattratttyp     = new MatrattTyp();
     mattratttyper   = new List <MatrattTyp>();
     MattrattProdukt = new List <MatrattProdukt>();
     Matratter       = new List <Matratt>();
     Matratteradded  = new List <Matratt>();
     Ingredins       = new Produkt();
     Ingredienses    = new List <Produkt>();
 }
Exemple #5
0
 public MenuPage()
 {
     Customer        = new Kund();
     NewDish         = new NewDishViewModel();
     matratt         = new Matratt();
     mattratttyp     = new MatrattTyp();
     mattratttyper   = new List <MatrattTyp>();
     MattrattProdukt = new List <MatrattProdukt>();
     Matratter       = new List <Matratt>();
     Matratteradded  = new List <Matratt>();
     Ingredins       = new Produkt();
     Ingredienses    = new List <Produkt>();
 }
Exemple #6
0
        public async Task <IActionResult> EditDishType(int typeId)
        {
            MatrattTyp model = await _repository.SelectById <MatrattTyp>(typeId);

            return(View(model));
        }