Exemple #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));
        }
Exemple #2
0
 public IActionResult OnGet(int id)
 {
     Post = _postData.Get(id);
     if (Post == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(Page());
 }
 public IActionResult OnGet(int?id)
 {
     Post = _postData.Get(id);
     if (Post == null)
     {
         return(RedirectToPage("/Index"));
     }
     return(Page());
 }
Exemple #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);
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #8
0
 public Post Get(int id)
 {
     return(source.Get(id));
 }
Exemple #9
0
        public IActionResult Get(int id)
        {
            var cm = _repo.Get(id);

            return(Ok(cm));
        }