public IHttpActionResult DislikePost([FromBody] string id)
 {
     try
     {
         var helper = new FormalBlogRepository();
         helper.DisLikePost(int.Parse(id), User.Identity.GetUserId());
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
 public IHttpActionResult Comment(List <string> funThings)
 {
     try
     {
         var helper = new FormalBlogRepository();
         helper.SaveComment(funThings[0], funThings[1], funThings[2]);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
 public IHttpActionResult LikePost(List <string> postId)
 {
     try
     {
         var helper = new FormalBlogRepository();
         helper.LikePost(int.Parse(postId[0]), postId[1]);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
 public IHttpActionResult GetPostsById(List <string> id)
 {
     try
     {
         var helper = new FormalBlogRepository();
         var model  = helper.GetPostById(int.Parse(id[0]));
         return(Ok(model));
     }
     catch
     {
         return(BadRequest());
     }
 }
 public IHttpActionResult RemovePost(List <string> blogid)
 {
     try
     {
         var helper = new FormalBlogRepository();
         helper.DeletePost(int.Parse(blogid[0]));
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
 public ActionResult FormalBlog()
 {
     try
     {
         var helper = new FormalBlogRepository();
         var model  = helper.GetFormalPosts();
         return(View(model));
     }
     catch
     {
         var model = new ListFormalBlogViewModel
         {
             Posts = new List <FormalBlogViewModel>()
         };
         return(View(model));
     }
 }
        public ActionResult FormalBlog(ListFormalBlogViewModel BlogList)
        {
            var helper = new FormalBlogRepository();

            if (!ModelState.IsValid)
            {
                var model = helper.GetFormalPosts();
                return(View(model));
            }

            try
            {
                BlogList.SenderId = User.Identity.GetUserId();
                helper.SavePost(BlogList);
                var model = helper.GetFormalPosts();
                return(RedirectToAction("FormalBlog"));
            }
            catch
            {
                ModelState.AddModelError("", "Något gick fel. Tänk på att du inte kan ladda upp bildfiler i den formella boggen.");
                var model = helper.GetFormalPosts();
                return(View(model));
            }
        }