示例#1
0
        public async Task <IActionResult> Create(BundelCreateViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(viewModel.BundelBeschrijving);
                int saveCheck = await _context.SaveChangesAsync();

                if (saveCheck != 0)
                {
                    viewModel.Bundel.BundelBeschrijvingID = viewModel.BundelBeschrijving.BundelBeschrijvingID;

                    List <BundelInhoud> bundelInhoud = new List <BundelInhoud>();
                    foreach (int cursusID in viewModel.GeselecteerdeCursussen)
                    {
                        bundelInhoud.Add(new BundelInhoud
                        {
                            CursusID = cursusID,
                            BundelID = viewModel.Bundel.BundelID
                        });
                    }
                    _context.Add(viewModel.Bundel);
                    await _context.SaveChangesAsync();

                    Bundel bundel = await _context.Bundels.Include(o => o.BundelInhoud)
                                    .SingleOrDefaultAsync(x => x.BundelID == viewModel.Bundel.BundelID);

                    bundel.BundelInhoud.AddRange(bundelInhoud);
                    _context.Update(bundel);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(viewModel));
        }
        public async Task <IActionResult> Buy(CursusDetailViewModel viewModel)
        {
            if (viewModel.IsLogged)
            {
                AccountCatalogus newItem = new AccountCatalogus
                {
                    CursusID    = viewModel.Cursus.CursusID,
                    Voortgang   = 1,
                    AccountID   = viewModel.CurrentUser.Id,
                    VerloopTijd = DateTime.Now.AddMonths(viewModel.Cursus.BeschikbaarheidInMaanden)
                };
                _context.Add(newItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Catalogus"));
            }
            throw new Exception();
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("LesID,Naam")] Les les)
        {
            if (ModelState.IsValid)
            {
                _context.Add(les);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(les));
        }
        public async Task <IActionResult> Create([Bind("AlertId,AlertTitel,InfoText1,InfoText2,DateOfCreation,DateOfExpiry")] AlertItem alertItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(alertItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(alertItem));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("DocentID,DocentNaam,DocentTitel,DocentAfbeeldingURL,DocentFB,DocentIG,DocentPin,DocentBio")] Docent docent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(docent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(docent));
        }
示例#6
0
        public async Task <IActionResult> Create([Bind("CatalogusItemID,CursusID,AccountID,VerloopTijd,Voortgang")] AccountCatalogus accountCatalogus)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accountCatalogus);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccountID"] = new SelectList(_context.Account, "Id", "Id", accountCatalogus.AccountID);
            ViewData["CursusID"]  = new SelectList(_context.Cursussen, "CursusID", "Afbeelding", accountCatalogus.CursusID);
            return(View(accountCatalogus));
        }