Пример #1
0
 public IHttpActionResult Comment(List <string> funThings)
 {
     try
     {
         var helper = new InformalBlogRepository();
         helper.SaveComment(funThings[0], funThings[1], funThings[2]);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
 public ActionResult InformalBlog()
 {
     try
     {
         var helper = new InformalBlogRepository();
         var model  = helper.GetInformalPosts();
         return(View(model));
     }
     catch
     {
         var model = new ListInformalBlogViewModel
         {
             Posts = new List <InformalBlogViewModel>()
         };
         return(View(model));
     }
 }
        public ActionResult InformalBlog(ListInformalBlogViewModel BlogList)
        {
            var helper = new InformalBlogRepository();

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

            try
            {
                BlogList.SenderId = User.Identity.GetUserId();
                helper.SavePost(BlogList);
                var model = helper.GetInformalPosts();
                return(RedirectToAction("InformalBlog"));
            }
            catch
            {
                ModelState.AddModelError("", "Något gick fel.");
                var model = helper.GetInformalPosts();
                return(View(model));
            }
        }