コード例 #1
0
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(NewUsers);
                db.SaveChanges();
                return(RedirectToPage("./AllUsers"));
            }

            return(Page());
        }
コード例 #2
0
 public IActionResult OnPost()
 {
     using (var db = new SpartaDB())
     {
         if (ModelState.IsValid)
         {
             db.Role.Add(NewRole);
             db.SaveChanges();
             return(RedirectToPage("/Role"));
         }
     }
     return(Page());
 }
コード例 #3
0
 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"));
 }
コード例 #4
0
 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"));
 }
コード例 #5
0
        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"));
        }
コード例 #6
0
 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"));
 }