using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Localization; using Yavsc.Models; namespace Yavsc.ViewComponents { public class CommentViewComponent : ViewComponent { private readonly ApplicationDbContext context; private readonly IStringLocalizer localizer; public CommentViewComponent(IStringLocalizer localizer, ApplicationDbContext context ) { this.context = context; this.localizer = localizer; } public async Task InvokeAsync(long id) { var comment = await context.Comment .Include(c => c.Children) .Include(c => c.Author) .FirstOrDefaultAsync(c => c.Id==id); if (comment == null) throw new InvalidOperationException(); ViewBag.apictlr = "/api/v1/blogcomments"; return View("Default", comment); } private string GetDebuggerDisplay() { return ToString(); } } }