コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("BestellingID,Artikel,Prijs,KlantID")] CreateBestellingViewModel viewModel)
        {
            if (id != viewModel.Bestelling.BestellingID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(viewModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BestellingExists(viewModel.Bestelling.BestellingID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            viewModel.Klanten = new SelectList(_context.Klanten, "KlantID", "Naam", viewModel.Bestelling.KlantID);
            return(View(viewModel));
        }
コード例 #2
0
        // GET: Bestelling/Create
        public IActionResult Create()
        {
            var viewModel = new CreateBestellingViewModel();

            viewModel.Bestelling = new Bestelling();
            viewModel.Klanten    = new SelectList(_context.Klanten, "KlantID", "Naam");
            return(View(viewModel));
        }
コード例 #3
0
        public async Task <IActionResult> Create(CreateBestellingViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(viewModel.Bestelling);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            viewModel.Klanten = new SelectList(_context.Klanten, "KlantID", "Naam", viewModel.Bestelling.KlantID);
            return(View(viewModel));
        }
コード例 #4
0
        // GET: Bestelling/Create
        public IActionResult Create()
        {
            CreateBestellingViewModel viewModel = new CreateBestellingViewModel();

            //viewModel.Persoon = _context.Personen.Find(id); //Hoe kan ik hier de ingelogde id vinden
            viewModel.Bestelling       = new Bestelling();
            viewModel.Bestelling.Datum = DateTime.Now.Date;
            viewModel.Productenlijst   = _context.Producten.Include(x => x.ProductType).ToList();


            //ViewData["PersoonID"] = new SelectList(_context.Personen, "Persoon_ID", "Achternaam");
            return(View(viewModel));
        }
コード例 #5
0
        public async Task <IActionResult> Create(CreateBestellingViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(viewModel.Bestelling);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //viewModel.Persoon = _context.Personen.Find(id);// hoe kan ik hier de ingelogde id vinden
            viewModel.Bestelling       = new Bestelling();
            viewModel.Bestelling.Datum = DateTime.Now.Date;
            viewModel.Productenlijst   = _context.Producten.Include(x => x.ProductType).ToList();
            return(View(viewModel));
        }
コード例 #6
0
        // GET: Bestelling/Edit/5
        public async Task <IActionResult> Edit(int?id, CreateBestellingViewModel viewModel)
        {
            if (id == null)
            {
                return(NotFound());
            }

            viewModel.Bestelling = await _context.Bestellingen.FindAsync(id);

            if (viewModel.Bestelling == null)
            {
                return(NotFound());
            }
            viewModel.Klanten = new SelectList(_context.Klanten, "KlantID", "Naam");
            return(View(viewModel));
        }