public bool Update(User model) { using (var db = new ExamSystemEntities()) { db.Entry <User>(model).State = EntityState.Modified; int result = db.SaveChanges(); return(result > 0 ? true : false); } }
public bool Remove(int id) { using (var db = new ExamSystemEntities()) { var model = Get(id); db.Users.Attach(model); db.Entry(model).State = EntityState.Deleted; var result = db.SaveChanges(); return(result > 0 ? true : false); } }
public bool Remove(int id) { using (var db = new ExamSystemEntities()) { var model = db.QuestionAnswers.Where(x => x.QuestionId == id).FirstOrDefault(); db.QuestionAnswers.Attach(model); db.Entry(model).State = EntityState.Deleted; var result = db.SaveChanges(); return(result > 0 ? true : false); } }
public ActionResult EditMe([Bind(Exclude = ("Teacher_CreatedOn,Level_Id,Department_Id,IsDeleted"))] tbl_Student EdStu) { if (Session["Studnet_Id"] == null || Session["Studnet_Name"] == null) { return(RedirectToAction("StudentLogin", "Home")); } else { if (ModelState.IsValid) { int id = (int)TempData["StudentId"]; var Stu = db.tbl_Student.Where(a => a.Student_Id == id).FirstOrDefault(); Stu.Student_Name = EdStu.Student_Name; Stu.Student_Email = EdStu.Student_Email; Stu.Student_Password = EdStu.Student_Password; Stu.Student_Phone = EdStu.Student_Phone; db.Entry(Stu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); } }
public virtual void Edit(T entity) { dbSet.Attach(entity); dataContext.Entry(entity).State = EntityState.Modified; }
public ActionResult EditAdmin([Bind(Exclude = ("Admin_CreatedOn,IsDeleted"))] tbl_Admin EdAdm) { // شرط بيستخدم إن لو في حد حاول يدخل الرابط وهو مش مسجل دخول فبيرجعه لصفحة تسجيل الدخول if (Session["Admin_Id"] == null || Session["Admin_Name"] == null) { return(RedirectToAction("AdminLogin", "Home")); } else { if (ModelState.IsValid) { int id = (int)TempData["AdminId"]; var adm = db.tbl_Admin.Where(a => a.Admin_Id == id).FirstOrDefault(); adm.Admin_Name = EdAdm.Admin_Name; adm.Admin_Email = EdAdm.Admin_Email; adm.Admin_Password = EdAdm.Admin_Password; adm.Admin_Phone = EdAdm.Admin_Phone; db.Entry(adm).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("AdminMangement")); } return(View()); } }