Example #1
0
        //viewing a post
        // GET: Posts/Details/5
        public ActionResult Details(int?id)
        {
            /**
             * //handle errors and edgecases
             * if (area_id == null || category_id == null)
             * {
             *  return HttpNotFound();
             * }
             * else if (!DbLayer.CheckIfAreaExists(area_id) || !DbLayer.CheckIfCategoryExists(category_id))
             * {
             *  return HttpNotFound();
             * }
             **/
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            else if (!DbLayer.CheckIfPostsExists((int)id))
            {
                return(HttpNotFound());
            }

            int post_id = (int)id;

            return(View(DbLayer.getPost(post_id)));
        }
Example #2
0
 //only allowed for admin, need to annotate
 // GET: Posts/Delete/5
 public ActionResult Delete(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     if (!DbLayer.CheckIfPostsExists((int)id))
     {
         return(HttpNotFound());
     }
     return(View(DbLayer.getPost((int)id)));
 }
Example #3
0
        //GET Posts/Respond/5
        public ActionResult Respond(int?id)
        {
            //handle errors
            if (id == null)
            {
                return(HttpNotFound());
            }
            if (!DbLayer.CheckIfPostsExists((int)id))
            {
                return(HttpNotFound());
            }

            Post post = DbLayer.getPost((int)id);

            return(View(post));
        }
Example #4
0
        public ActionResult Respond([Bind(Include = "messageID,messageTimestamp,senderID,receiverID,body")] Message message, string area_id, string category_id, int?id)
        {
            //handle errors
            if (id == null)
            {
                return(HttpNotFound());
            }
            if (!DbLayer.CheckIfPostsExists((int)id))
            {
                return(HttpNotFound());
            }

            Post post = DbLayer.getPost((int)id);

            ViewBag.Message = message;

            if (ModelState.IsValid)
            {
                DbLayer.addMessageForPost((int)id, message);
                DbLayer.addMessageForUser(message.senderID, message);
                return(RedirectToAction("Details", new { area_id = area_id, category_id = category_id, id = id }));
            }
            return(View(post));
        }