public ActionResult Edit([Bind(Include = "OtherProjectId,Title,Description,Organization")] OtherProject otherProject) { if (Session["UserId"] == null) { return(RedirectToAction("Login", "Home")); } if (ModelState.IsValid) { db.Entry(otherProject).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(otherProject)); }
// GET: OtherProjects/Details/5 public ActionResult Details(int?id) { if (Session["UserId"] == null) { return(RedirectToAction("Login", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OtherProject otherProject = db.OtherProjects.Find(id); if (otherProject == null) { return(HttpNotFound()); } return(View(otherProject)); }
public ActionResult DeleteConfirmed(int id) { if (Session["UserId"] == null) { return(RedirectToAction("Login", "Home")); } int userId = Convert.ToInt32(Session["UserId"]); OtherProject otherProject = db.OtherProjects.Include("Student").Where(s => s.OtherProjectId == id).FirstOrDefault(); if (otherProject.Student.User.UserId != userId) { TempData["msg"] = "Kindly login with connected account"; RedirectToAction("Login", "Home"); } db.OtherProjects.Remove(otherProject); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "OtherProjectId,Title,Description,Organization")] OtherProject otherProject) { if (Session["UserId"] == null) { return(RedirectToAction("Login", "Home")); } if (ModelState.IsValid) { int userId = Convert.ToInt32(Session["UserId"]); var student = db.Students.Where(s => s.User.UserId == userId).FirstOrDefault(); if (student == null) { TempData["msg"] = "No student information found!"; return(RedirectToAction("Login", "Home")); } student.OtherProjects.Add(otherProject); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(otherProject)); }
// GET: OtherProjects/Edit/5 public ActionResult Edit(int?id) { if (Session["UserId"] == null) { return(RedirectToAction("Login", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } int userId = Convert.ToInt32(Session["UserId"]); OtherProject otherProject = db.OtherProjects.Include("Student").Where(s => s.OtherProjectId == id).FirstOrDefault(); if (otherProject.Student.User.UserId != userId) { TempData["msg"] = "Kindly login with connected account"; RedirectToAction("Login", "Home"); } if (otherProject == null) { return(HttpNotFound()); } return(View(otherProject)); }