public async Task <IActionResult> OnPostAsync() { if (HttpContext.Session.GetString("Test") != "1") { return(RedirectToPage("/Login")); } if (!ModelState.IsValid) { return(Page()); } _context.Attach(Role).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoleExists(Role.RoleID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (HttpContext.Session.GetString("Test") != "1") { return(RedirectToPage("/Login")); } if (id == null) { return(NotFound()); } Cohort = await _context.Cohorts.FindAsync(id); UserL = await _context.Users .Include(u => u.Role).Where(m => m.CohortID == id).ToListAsync(); if (Cohort != null) { if (UserL == null) { _context.Cohorts.Remove(Cohort); await _context.SaveChangesAsync(); } else if (UserL != null) { return(RedirectToPage("./Index"));; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (HttpContext.Session.GetString("Test") != "1") { return(RedirectToPage("/Login")); } if (!ModelState.IsValid) { ViewData["CohortID"] = new SelectList(_context.Cohorts, "CohortID", "CohortID"); ViewData["RoleID"] = new SelectList(_context.Roles, "RoleID", "RoleName"); return(Page()); } _context.Attach(User).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(User.UserID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (HttpContext.Session.GetString("Test") != "1") { return(RedirectToPage("/Login")); } if (!ModelState.IsValid) { return(Page()); } _context.Roles.Add(Role); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (HttpContext.Session.GetString("Test") != "1") { return(RedirectToPage("/Login")); } if (!ModelState.IsValid) { OnGet(); return(Page()); } User.Password = Hash.HashPW(User.Password); _context.Users.Add(User); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (HttpContext.Session.GetString("Test") != "1") { return(RedirectToPage("/Login")); } if (id == null) { return(NotFound()); } User = await _context.Users.FindAsync(id); if (User != null) { _context.Users.Remove(User); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }