Summary

Class:ProjectX.PublicApi.Actions.Categories.CategoriesController
Assembly:ProjectX.PublicApi
File(s):C:\private\projects\projectx\backend\src\ProjectX.PublicApi\Actions\Categories\CategoriesController.cs
Covered lines:15
Uncovered lines:0
Coverable lines:15
Total lines:48
Line coverage:100%

History

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
.ctor(...)10100100
Get()30100100

File(s)

C:\private\projects\projectx\backend\src\ProjectX.PublicApi\Actions\Categories\CategoriesController.cs

#LineLine coverage
 1using System.Threading.Tasks;
 2using Microsoft.AspNetCore.Mvc;
 3using Microsoft.Extensions.Logging;
 4using ProjectX.PublicApi.Filters;
 5using ProjectX.Stores;
 6
 7namespace ProjectX.PublicApi.Actions.Categories
 8{
 9    [ServiceFilter(typeof(AuthContextAttribute))]
 10    [Route("/categories")]
 11    public class CategoriesController : Controller
 12    {
 13        private readonly ILogger<CategoriesController> _logger;
 14        private readonly IEventCategoryStore _categoryStore;
 15
 616        public CategoriesController(
 617            ILogger<CategoriesController> logger,
 618            IEventCategoryStore categoryStore)
 19        {
 620            this._logger = logger;
 621            this._categoryStore = categoryStore;
 622        }
 23
 24        /// <summary>
 25        /// Get list of event categories
 26        /// </summary>
 27        /// <param name="query"></param>
 28        /// <returns></returns>
 29        [HttpGet]
 30        [ValidateModel]
 31        public async Task<IActionResult> Get(
 32            [FromQuery]GetCategoriesQuery query)
 33        {
 234            this._logger.LogTrace("Start category get request");
 35
 236            var categoryList = await _categoryStore.LoadEventCategoriesAsync(
 237                take: query.Take,
 238                skip: query.Skip
 239            );
 40
 241            var result = categoryList.ToModel();
 42
 243            this._logger.LogTrace("End category get request");
 44
 245            return new ObjectResult(result);
 246        }
 47    }
 48}