Пример #1
0
        // GET: Posts/Details/5
        public ActionResult Details(int id)
        {
            var model = _db.Get(id);

            ViewBag.DateCreated = model.DateCreated.ToString("dddd , MMM dd yyyy,hh:mm");
            ViewBag.DateEdited  = model.DateEdited.ToString("dddd , MMM dd yyyy,hh:mm");
            if (model == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
Пример #2
0
 public IActionResult OnGet(int id)
 {
     Post = _postData.Get(id);
     if (Post == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(Page());
 }
Пример #3
0
 public IActionResult OnGet(int?id)
 {
     Post = _postData.Get(id);
     if (Post == null)
     {
         return(RedirectToPage("/Index"));
     }
     return(Page());
 }
Пример #4
0
        public Comment Add(Comment comment, int postId)
        {
            var post = _postData.Get(postId);

            comment.Post = post;

            _context.Comments.Add(comment);
            _context.SaveChanges();
            return(comment);
        }
Пример #5
0
        public IActionResult Details(int id)
        {
            var model = new DetailPostViewModel {
                Post = _postData.Get(id)
            };

            if (model == null)
            {
                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
Пример #6
0
        public ActionResult PostDetails(int id)
        {
            var post = postData.Get(id);

            if (post == null)
            {
                return(View("NotFound"));
            }

            var model = new PostViewModel {
                Post = post, Comments = commentData.GetAllForPost(post.ID)
            };

            return(View(model));
        }
Пример #7
0
        public IActionResult Details(int id)
        {
            var post = _postData.Get(id);

            if (post == null)
            {
                return(RedirectToAction("Index"));
            }
            var dvm = new DetailsViewModel()
            {
                Post     = post,
                Comments = _commentData.GetByPost(post.Id)
            };

            return(View(dvm));
        }
Пример #8
0
 public Post Get(int id)
 {
     return(source.Get(id));
 }
Пример #9
0
        public IActionResult Get(int id)
        {
            var cm = _repo.Get(id);

            return(Ok(cm));
        }