starting a tagger component
This commit is contained in:
parent
3fe818b4f1
commit
22e5259b91
9 changed files with 291 additions and 3 deletions
33
Yavsc/ViewComponents/TaggerComponent.cs
Normal file
33
Yavsc/ViewComponents/TaggerComponent.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yavsc.Interfaces;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.ViewComponents
|
||||
{
|
||||
public class TaggerViewComponent : ViewComponent
|
||||
|
||||
{
|
||||
ApplicationDbContext dbContext;
|
||||
IStringLocalizer<TaggerViewComponent> localizer;
|
||||
ILogger logger ;
|
||||
public TaggerViewComponent(
|
||||
ApplicationDbContext pdbContext,
|
||||
IStringLocalizer<TaggerViewComponent> pLocalizer,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
dbContext = pdbContext;
|
||||
this.localizer = pLocalizer;
|
||||
this.logger = loggerFactory.CreateLogger<TaggerViewComponent>();
|
||||
}
|
||||
public IViewComponentResult Invoke(ITaggable<long> longTaggable)
|
||||
{
|
||||
ViewData["Tags"] = longTaggable.GetTags();
|
||||
ViewData["at"] = localizer["at"];
|
||||
ViewData["apictlr"] = "~/api/"+localizer["apiRouteTag"+longTaggable.GetType().Name];
|
||||
return View(longTaggable);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue