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

            return(Ok(cm));
        }