public ActionResult DeleteConfirmed(int id) { Student_174852 student_174852 = db.Student_174852.Find(id); db.Student_174852.Remove(student_174852); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Login(Student_174852 user) { using (Training_20Feb_MumbaiEntity db = new Training_20Feb_MumbaiEntity()) { var usr = db.Student_174852.Where(u => u.Username == user.Username && u.Password == user.Password).FirstOrDefault(); if (usr != null) { Session["StudentId"] = usr.StudentId.ToString(); Session["Username"] = usr.Username.ToString(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Username or Password is wrong."); } } return(View()); }
public ActionResult Edit([Bind(Include = "StudentId,Username,FName,LName,Address,DOB,City,Password,MobileNo")] Student_174852 student_174852) { if (Session["TeacherId"] != null) { if (ModelState.IsValid) { db.Entry(student_174852).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StudentId = new SelectList(db.Planning_174852, "StudentId", "Monday", student_174852.StudentId); return(View(student_174852)); } else { return(RedirectToAction("Login", "Admin")); } }
public ActionResult Register(Student_174852 stud) { if (stud == null) { ViewBag.Message = "Please Enter Data"; } if (ModelState.IsValid) { using (Training_20Feb_MumbaiEntity db = new Training_20Feb_MumbaiEntity()) { db.Student_174852.Add(stud); db.SaveChanges(); ViewBag.Message = "Successfully Registered."; } ModelState.Clear(); ViewBag.Message = stud.FName + " " + stud.LName + "successfully registered"; } return(View()); }
// GET: Admi1/Details/5 public ActionResult Details(int?id) { if (Session["TeacherId"] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Student_174852 student_174852 = db.Student_174852.Find(id); if (student_174852 == null) { return(HttpNotFound()); } return(View(student_174852)); } else { return(RedirectToAction("Login", "Admin")); } }
// GET: Admi1/Edit/5 public ActionResult Edit(int?id) { if (Session["TeacherId"] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Student_174852 student_174852 = db.Student_174852.Find(id); if (student_174852 == null) { return(HttpNotFound()); } ViewBag.StudentId = new SelectList(db.Planning_174852, "StudentId", "Monday", student_174852.StudentId); return(View(student_174852)); } else { return(RedirectToAction("Login", "Admin")); } }
public ActionResult Update(string FName, string LName, string Address, DateTime DOB, string City, string MobileNo, int StudentId) { TempData.Clear(); if (Session["StudentId"] != null) { try { if (ModelState.IsValid) { Student_174852 std = s.Student_174852.Where(x => x.StudentId == StudentId).FirstOrDefault(); if (std != null) { std.FName = FName; std.LName = LName; std.Address = Address; std.DOB = DOB; std.City = City; std.MobileNo = MobileNo; s.SaveChanges(); TempData["Updated"] = true; return(RedirectToAction("Index", "Student")); } else { TempData["Message"] = "You are not authorized."; return(RedirectToAction("Login")); } } return(View()); } catch (Exception ex) { TempData["message"] = "Some error occured"; return(View()); } } return(View()); }
public ActionResult Update() { if (Session["StudentId"] != null) { try { int id = Convert.ToInt32(Session["StudentId"]); Student_174852 stud = s.Student_174852.Where(e => e.StudentId == id).FirstOrDefault(); if (stud == null) { return(HttpNotFound()); } return(View(stud)); } catch (System.NullReferenceException ex) { return(RedirectToAction("Index", "Student")); } } else { return(RedirectToAction("Login")); } }