public async Task <IActionResult> DeleteConfirmed(string id) { var deelnemer = await _context.ApplicationUsers.SingleOrDefaultAsync(m => m.Id == id); await _userManager.DeleteAsync(deelnemer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("Id,Naam,Rgb,BadgeCode")] Track track) { if (ModelState.IsValid) { _context.Add(track); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(track)); }
// GET: Maxima public async Task <IActionResult> Index() { var maxima = await _context.Maxima.SingleOrDefaultAsync(); if (maxima == null) { // if maxima table empty create placeholder record maxima = new Maxima { MaxRDW = 0, MaxNonRDW = 0 }; _context.Maxima.Add(maxima); await _context.SaveChangesAsync(); } int confirmedUserCount = await ApplicationUser.ConfirmedUserCountAsync(_context); int unconfirmedUserCount = await ApplicationUser.UnconfirmedUserCountAsync(_context); int confirmedRdwUserCount = await ApplicationUser.ConfirmedRdwUserCountAsync(_context); int confirmedNonRdwUserCount = await ApplicationUser.ConfirmedNonRdwUserCountAsync(_context); int rdwUserCount = await ApplicationUser.RdwUserCountAsync(_context); int nonRdwUserCount = await ApplicationUser.NonRdwuserCountAsync(_context); ViewBag.ConfirmedUserCount = confirmedUserCount.ToString(); ViewBag.UnconfirmedUserCount = unconfirmedUserCount.ToString(); ViewBag.ConfirmedRdwUserCount = confirmedRdwUserCount.ToString(); ViewBag.ConfirmedNonRdwUserCount = confirmedNonRdwUserCount.ToString(); ViewBag.UnconfirmedRdwUserCount = rdwUserCount - confirmedRdwUserCount; ViewBag.UnconfirmedNonRdwUserCount = nonRdwUserCount - confirmedNonRdwUserCount; List <ApplicationUser> users = await _context.ApplicationUsers .Include(t => t.ApplicationUserTijdvakken) /* this is to filter older users that did not have a datecreated field as they where created before adding the field */ .Where(t => t.DateCreated > new System.DateTime(2017, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)) .OrderByDescending(t => t.DateCreated) .Take(20) .ToListAsync(); List <ApplicationUser> unverifiedUsers = await _context.ApplicationUsers .Include(t => t.ApplicationUserTijdvakken) .Where(t => t.EmailConfirmed == false) .OrderByDescending(t => t.DateCreated) .ToListAsync(); maxima.LastCreatedUsers = users; maxima.UnverifiedUsers = unverifiedUsers; return(View(maxima)); }
public async Task <IActionResult> Create([Bind("Id,Naam,TrackId,RuimteId")] Sessie sessie, string[] selectedTijdvakken) { if (ModelState.IsValid) { _context.Add(sessie); UpdateSessieTijdvakken(selectedTijdvakken, sessie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } PopulateTracksDropDownList(sessie.TrackId); PopulateRuimtesDropDownList(sessie.RuimteId); PopulateSessieTijdvakData(sessie); return(View(sessie)); }