Beispiel #1
0
        //Get post by post urlslug
        public ViewResult Post(string urlslug)
        {
            logginghelper.Log(LoggingLevels.Info, "Class: " + classname + " :: Post - Begin");
            Post post = null;

            try
            {
                post = dataaccess.Post(urlslug, null);
                post.PostNavDetails = dataaccess.GetNextAndPreviousPostIds(post.PostId);
                User objuser = dataaccess.GetUserList().Where(x => x.UserId.Equals(post.UserId)).FirstOrDefault();
                ViewBag.AuthorName = objuser.FirstName + " " + objuser.LastName;
                if (post == null)
                {
                    throw new HttpException(404, "Post Not Found");
                }
                else if (post.IsPublished == false && User.Identity.IsAuthenticated == false)
                {
                    throw new HttpException(401, "Post Not Published");
                }
            }
            catch (Exception ex)
            {
                logginghelper.Log(LoggingLevels.Error, "Class: " + classname + " :: Post " + ex);
            }
            logginghelper.Log(LoggingLevels.Info, "Class: " + classname + " :: Post - End");
            return(View(post));
        }