Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
        // 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));
        }
Exemplo n.º 3
0
        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"));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        // 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));
        }