示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("CatalogusItemID,CursusID,AccountID,VerloopTijd,Voortgang")] AccountCatalogus accountCatalogus)
        {
            if (id != accountCatalogus.CatalogusItemID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accountCatalogus);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountCatalogusExists(accountCatalogus.CatalogusItemID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }
示例#2
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));
        }
        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();
        }
示例#4
0
        public async Task <IActionResult> Buy(BundelDetailsViewModel viewModel)
        {
            if (viewModel.IsLogged)
            {
                foreach (BundelInhoud cursus in viewModel.Bundel.BundelInhoud)
                {
                    AccountCatalogus newItem = new AccountCatalogus
                    {
                        CursusID    = cursus.Cursus.CursusID,
                        Voortgang   = 1,
                        AccountID   = viewModel.CurrentUser.Id,
                        VerloopTijd = DateTime.Now.AddMonths(cursus.Cursus.BeschikbaarheidInMaanden)
                    };
                    _context.Add(newItem);
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            throw new Exception();
        }