add rule count to result of rules API controller

ref #272
This commit is contained in:
Collin M. Barrett 2018-06-07 12:45:44 -05:00
parent 27ce0aa0e5
commit fe1b7e9a5c
3 changed files with 26 additions and 2 deletions

View file

@ -10,6 +10,10 @@ public class BaseController : Controller
{
protected readonly SeedService SeedService;
public BaseController()
{
}
protected BaseController(SeedService seedService)
{
SeedService = seedService;

View file

@ -0,0 +1,19 @@
using System.Threading.Tasks;
using FilterLists.Services;
using Microsoft.AspNetCore.Mvc;
namespace FilterLists.Api.V1.Controllers
{
public class RulesController : BaseController
{
private readonly RuleService _ruleService;
public RulesController(RuleService ruleService)
{
_ruleService = ruleService;
}
[HttpGet]
public async Task<IActionResult> Index() => Json(new {Count = await _ruleService.GetCountAllActiveRules()});
}
}

View file

@ -20,9 +20,10 @@ public static void AddFilterListsServices(this IServiceCollection services, ICon
options.UseMySql(configuration.GetConnectionString("FilterListsConnection"),
b => b.MigrationsAssembly("FilterLists.Api"))
.EnableSensitiveDataLogging());
services.TryAddScoped<FilterListService>();
services.TryAddScoped<SeedService>();
services.TryAddScoped<SnapshotService>();
services.TryAddScoped<FilterListService>();
services.TryAddScoped<RuleService>();
services.TryAddScoped<SeedService>();
services.AddAutoMapper();
}
}