Blog comment comments
parent
d4d02b967d
commit
ee25a01946
@ -1,94 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Yavsc.ViewComponents {
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public partial class CommentViewComponent {
|
||||
|
||||
private static System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.Equals(null, resourceMan)) {
|
||||
System.Resources.ResourceManager temp = new System.Resources.ResourceManager(("Yavsc.Resources." + "Yavsc.ViewComponents.CommentViewComponent"), typeof(CommentViewComponent).GetTypeInfo().Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static string apiRouteCommentBlogPost {
|
||||
get {
|
||||
return ResourceManager.GetString("apiRouteCommentBlogPost", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string CommmentId {
|
||||
get {
|
||||
return ResourceManager.GetString("CommmentId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Comment {
|
||||
get {
|
||||
return ResourceManager.GetString("Comment", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string LastModificationDate {
|
||||
get {
|
||||
return ResourceManager.GetString("LastModificationDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string CreationDate {
|
||||
get {
|
||||
return ResourceManager.GetString("CreationDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string PostId {
|
||||
get {
|
||||
return ResourceManager.GetString("PostId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string UserCreated {
|
||||
get {
|
||||
return ResourceManager.GetString("UserCreated", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string UserModified {
|
||||
get {
|
||||
return ResourceManager.GetString("UserModified", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,21 +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 partial class CommentViewComponent : ViewComponent
|
||||
public class CommentViewComponent : ViewComponent
|
||||
{
|
||||
private readonly ApplicationDbContext context;
|
||||
private readonly IStringLocalizer<CommentViewComponent> localizer;
|
||||
public CommentViewComponent(IStringLocalizer<CommentViewComponent> localizer)
|
||||
public CommentViewComponent(IStringLocalizer<CommentViewComponent> localizer,
|
||||
ApplicationDbContext context
|
||||
)
|
||||
{
|
||||
this.context = context;
|
||||
this.localizer = localizer;
|
||||
}
|
||||
public IViewComponentResult Invoke(IIdentified<long> longCommentable)
|
||||
public async Task<IViewComponentResult> InvokeAsync(long id)
|
||||
{
|
||||
// for a BlogPost, it results in the localization 'apiRouteCommentBlogPost': blogcomments
|
||||
ViewData["apictlr"] = "/api/"+localizer["apiRouteComment"+longCommentable.GetType().Name];
|
||||
return View(longCommentable.GetType().Name, new Comment{ ReceiverId = longCommentable.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +0,0 @@
|
||||
@model Comment
|
||||
Loading…
Reference in New Issue