Ejemplo n.º 1
0
        public IActionResult ShowPartialWithViewModel()
        {
            BlogCommentVM vm = new BlogCommentVM();

            vm.Blogs    = _context.Blog.ToList();
            vm.Comments = _context.Comment.ToList();

            return(View(vm));
        }
Ejemplo n.º 2
0
        public BlogCommentVM GetBlogData(int blogId)
        {
            BlogCommentVM vm;

            var blog     = db.Blogs.Find(blogId);
            var comments = db.Comments.Where(x => x.BlogId == blogId).ToList();

            vm = new BlogCommentVM()
            {
                Blogs    = blog,
                Comments = comments
            };

            return(vm);
        }
Ejemplo n.º 3
0
        public ActionResult Detay(BlogCommentVM vm, int id)
        {
            try
            {
                vm.Comment.BlogId = id;
                db.Comments.Add(vm.Comment);
                db.SaveChanges();

                ViewBag.Success = "True";
            }
            catch (Exception)
            {
                ViewBag.Success = "False";
            }

            return(View(GetBlogData(id)));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> BlogComment(BlogCommentVM blogCommentVM)
        {
            BlogComment blogComment = new BlogComment()
            {
                Blog        = _context.Blogs.Find(blogCommentVM.id),
                Name        = blogCommentVM.name,
                Email       = blogCommentVM.email,
                Subject     = blogCommentVM.subject,
                Description = blogCommentVM.message
            };

            await _context.BlogComments.AddAsync(blogComment);

            await _context.SaveChangesAsync();

            //return View();
            return(Content("Success!!!"));
        }