public IActionResult OnPost() { if (ModelState.IsValid) { db.Users.Add(NewUsers); db.SaveChanges(); return(RedirectToPage("./AllUsers")); } return(Page()); }
public IActionResult OnPost() { using (var db = new SpartaDB()) { if (ModelState.IsValid) { db.Role.Add(NewRole); db.SaveChanges(); return(RedirectToPage("/Role")); } } return(Page()); }
public IActionResult OnPost() { // using (var db = new SpartaDB()) // { if (!ModelState.IsValid) { return(Page()); } db.Entry(RoleSelected).Property(x => x.RoleName).IsModified = true; db.SaveChanges(); // } return(RedirectToPage("ViewUsers")); }
public IActionResult OnPost() { // using (var db = new SpartaDB()) // { if (!ModelState.IsValid) { return(Page()); } db.Entry(CohortSelected).Property(x => x.CohortName).IsModified = true; db.Entry(CohortSelected).Property(x => x.SpecialisationID).IsModified = true; db.SaveChanges(); // } return(RedirectToPage("ViewCohort")); }
public IActionResult OnGetDelete(int id) { if (id != null) { using (var db = new SpartaDB()) { var data = (from o in db.Users where o.UsersID == id select o).SingleOrDefault(); db.Remove(data); db.SaveChanges(); } } return(RedirectToPage("./Cohort")); }
public IActionResult OnPost() { // using (var db = new SpartaDB()) // { if (!ModelState.IsValid) { return(Page()); } db.Entry(UserSelected).Property(x => x.FirstName).IsModified = true; db.Entry(UserSelected).Property(x => x.LastName).IsModified = true; db.Entry(UserSelected).Property(x => x.Email).IsModified = true; db.Entry(UserSelected).Property(x => x.Password).IsModified = true; db.Entry(UserSelected).Property(x => x.CohortID).IsModified = true; db.Entry(UserSelected).Property(x => x.RoleID).IsModified = true; db.SaveChanges(); // } return(RedirectToPage("ViewUsers")); }