public async Task <IActionResult> PutCursusBeschrijving(int id, CursusBeschrijving cursusBeschrijving) { if (id != cursusBeschrijving.CursusBeschrijvingID) { return(BadRequest()); } _context.Entry(cursusBeschrijving).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CursusBeschrijvingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutDocent(int id, Docent docent) { if (id != docent.DocentID) { return(BadRequest()); } _context.Entry(docent).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DocentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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)); }
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)); }
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> 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(); }
public async Task Save() { await _context.SaveChangesAsync(); }