Пример #1
0
 public ActionResult StudentRegister(RegisterStudent regStu)
 {
     if (ModelState.IsValid)
     {
         if (!db.tbl_Student.Any(x => x.Student_Email == regStu.Student_Email))
         {
             tbl_Student stu = new tbl_Student();
             stu.Student_Name      = regStu.Student_Name;
             stu.Student_Email     = regStu.Student_Email;
             stu.Student_Phone     = regStu.Student_Phone;
             stu.Student_Password  = regStu.Password;
             stu.Student_CreatedOn = DateTime.Now;
             stu.Level_Id          = regStu.Level_Id;
             stu.Department_Id     = regStu.Department_ID;
             stu.IsDeleted         = false;
             db.tbl_Student.Add(stu);
             db.SaveChanges();
             return(RedirectToAction("StudentLogin"));
         }
         else
         {
             ViewBag.mssg = "هذا الحساب موجود بالفعل";
             List <tbl_Level>      levlist = db.tbl_Level.ToList();
             List <tbl_Department> Deplist = db.tbl_Department.ToList();
             ViewData["Levels"]      = new SelectList(levlist, "Level_Id", "Level_Name");
             ViewData["Departments"] = new SelectList(Deplist, "Department_Id", "Department_Name");
         }
     }
     return(View(regStu));
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
 public bool Remove(User model)
 {
     using (var db = new ExamSystemEntities())
     {
         db.Users.Remove(model);
         int result = db.SaveChanges();
         return(result > 0 ? true : false);
     }
 }
Пример #4
0
 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());
     }
 }
Пример #7
0
 public bool Insert(User model)
 {
     try
     {
         using (var db = new ExamSystemEntities())
         {
             db.Set <User>().Add(model);
             int result = db.SaveChanges();
             return(result > 0 ? true : false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Пример #8
0
 public ActionResult AddAdmin(AdminMangementModel AddAdmin)
 {
     // شرط بيستخدم إن لو في حد حاول يدخل الرابط وهو مش مسجل دخول فبيرجعه لصفحة تسجيل الدخول
     if (Session["Admin_Id"] == null || Session["Admin_Name"] == null)
     {
         return(RedirectToAction("AdminLogin", "Home"));
     }
     else
     {
         if (ModelState.IsValid)
         {
             // التأكد أن البريد المدخل ليس موجود مسبقا
             if (!db.tbl_Admin.Any(x => x.Admin_Email == AddAdmin.Admin_Email))
             {
                 tbl_Admin adm = new tbl_Admin();
                 adm.Admin_Name      = AddAdmin.Admin_Name;
                 adm.Admin_Email     = AddAdmin.Admin_Email;
                 adm.Admin_Password  = AddAdmin.Password;
                 adm.Admin_Phone     = AddAdmin.Admin_Phone;
                 adm.Admin_CreatedOn = DateTime.Now;
                 adm.IsDeleted       = false;
                 db.tbl_Admin.Add(adm);
                 db.SaveChanges();
                 return(RedirectToAction("AdminMangement"));
             }
             else
             {
                 ViewBag.msg = "هذا الحساب موجود بالفعل";
             }
         }
         return(View(AddAdmin));
     }
 }