public ActionResult DeleteConfirmed(int id) { CustomLogger = new CustomLogger(); Students students = db.Students.Find(id); db.Students.Remove(students); db.SaveChanges(); CustomLogger.LogFunction(DateTime.Now.ToString() + " " + "Removed " + " " + id); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Name,Age,Major,Average,ClassName,UserId")] Students students) { CustomLogger = new CustomLogger(); context = new ApplicationDbContext(); var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context)); ApplicationUser currentUser = UserManager.FindById(User.Identity.GetUserId()); students.UserId = currentUser.Id; if (ModelState.IsValid) { db.Entry(students).State = EntityState.Modified; db.SaveChanges(); CustomLogger.LogFunction(DateTime.Now.ToString() + " " + EntityState.Modified + students.Name + " " + students.ID + " "); return(RedirectToAction("Index")); } ViewBag.ClassName = new SelectList(db.Classes, "ClassId", "ClassName", students.ClassName); return(View(students)); }