reorg
This commit is contained in:
parent
d000f77098
commit
40e8e08690
3487 changed files with 39 additions and 21 deletions
35
src/Yavsc.Org/ViewComponents/CommentViewComponent.cs
Normal file
35
src/Yavsc.Org/ViewComponents/CommentViewComponent.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Blog;
|
||||
|
||||
namespace Yavsc.ViewComponents
|
||||
{
|
||||
public class CommentViewComponent : ViewComponent
|
||||
{
|
||||
private readonly ApplicationDbContext context;
|
||||
private readonly IStringLocalizer<CommentViewComponent> localizer;
|
||||
public CommentViewComponent(IStringLocalizer<CommentViewComponent> localizer,
|
||||
ApplicationDbContext context
|
||||
)
|
||||
{
|
||||
this.context = context;
|
||||
this.localizer = localizer;
|
||||
}
|
||||
public async Task<IViewComponentResult> InvokeAsync(long id)
|
||||
{
|
||||
var comment = await context.Comment.Include(c=>c.Children).FirstOrDefaultAsync(c => c.Id==id);
|
||||
if (comment == null)
|
||||
throw new InvalidOperationException();
|
||||
ViewData["apictlr"] = "/api/blogcomments";
|
||||
return View("Default", comment);
|
||||
}
|
||||
|
||||
private string GetDebuggerDisplay()
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue