コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            LISTING listing = db.LISTINGS.Find(id);

            if (authenticateUser(listing.userid))
            {
                return(RedirectToAction("MyProjects"));
            }
            db.LISTINGS.Remove(listing);
            db.SaveChanges();
            return(RedirectToAction("MyProjects"));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "projectid,userid,title,listingType,seeker,discipline,description,email,contactnumber,subcategory,supervisors,timeframe,startdate,expiredate,mode,location")] LISTING listing)
        {
            if (ModelState.IsValid)
            {
                listing.userid = User.Identity.GetUserId();
                db.LISTINGS.Add(listing);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.userid = new SelectList(db.PROFILES, "userid", "firstname", listing.userid);
            return(RedirectToAction("MyProjects", "Listings"));
        }
コード例 #3
0
        // GET: Listings/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Manage"));
            }
            LISTING listings = db.LISTINGS.Find(id);

            if (listings == null)
            {
                return(HttpNotFound());
            }
            return(View(listings));
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "projectid,userid,title,listingType,seeker,discipline,description,email,contactnumber,subcategory,supervisors,timeframe,startdate,expiredate,mode,location")] LISTING listing)
 {
     if (authenticateUser(listing.userid))
     {
         return(RedirectToAction("MyProjects"));
     }
     if (ModelState.IsValid)
     {
         db.Entry(listing).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.userid = new SelectList(db.PROFILES, "userid", "firstname", listing.userid);
     return(View(listing));
 }
コード例 #5
0
        // GET: Listings/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LISTING listing = db.LISTINGS.Find(id);

            if (authenticateUser(listing.userid))
            {
                return(RedirectToAction("MyProjects"));
            }
            if (listing == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View(listing));
        }
コード例 #6
0
        // GET: Listings/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("MyProjects", "Listings"));
            }
            LISTING listing = db.LISTINGS.Find(id);

            if (listing == null)
            {
                TempData["errorMessage"] = "Listing not found";
                return(RedirectToAction("MyProjects", "Listings"));
            }
            if (authenticateUser(listing.userid))
            {
                return(RedirectToAction("MyProjects"));
            }
            ViewBag.userid = new SelectList(db.PROFILES, "userid", "firstname", listing.userid);
            return(View(listing));
        }