Beispiel #1
0
        public async Task <IActionResult> Create([Bind("FutarId,Nev")] Futar futar)
        {
            if (ModelState.IsValid)
            {
                _context.Add(futar);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(futar));
        }
        public async Task <IActionResult> Create([Bind("MegrendeloId,Nev")] Megrendelo megrendelo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(megrendelo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(megrendelo));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("CimId,Irsz,Varos,Utca,Hazszam,Csengo,MegrendeloId")] Cim cim)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cim);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MegrendeloId"] = new SelectList(_context.Megrendelok, "MegrendeloId", "Nev", cim.MegrendeloId);
            return(View(cim));
        }
        public async Task <IActionResult> Create([Bind("CimId")] Rendeles rendeles)
        {
            if (rendeles.CimId == null)
            {
                ModelState.AddModelError("Error", "A rendeléshez szükséges a megrendelő címe! ");
                PopulateCimDropDownList();
                PopulatePizzaDropDownList();
                return(View(rendeles));
            }

            // pizzak osszeszedese
            var pizzakSessionbol = HttpContext.Session.GetString("pids");

            string[] pizzak = pizzakSessionbol.Split(' ');
            pizzak = pizzak.Take(pizzak.Count() - 1).ToArray();

            if (pizzak.Length == 0)
            {
                ModelState.AddModelError("Error", "A rendeléshez szükséges legalább egy pizzát hozzáadni! ");
                PopulateCimDropDownList();
                PopulatePizzaDropDownList();
                return(View(rendeles));
            }

            if (ModelState.IsValid)
            {
                // uj rendeles
                rendeles.AllapotId = 1;
                _context.Add(rendeles);
                await _context.SaveChangesAsync();

                // pizzak hozzaad
                foreach (var p in pizzak)
                {
                    PizzaRendeles pr = new PizzaRendeles
                    {
                        PizzaId    = int.Parse(p),
                        RendelesId = rendeles.RendelesId
                    };
                    _context.Add(pr);
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rendeles));
        }