Last active
February 24, 2019 15:33
-
-
Save evgomes/1c82c93ad1d58694afebea87afa01113 to your computer and use it in GitHub Desktop.
CategoriesController after creating ICategoryService and first HTTP GET, from Supermarket API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
using Supermarket.API.Domain.Models; | |
using Supermarket.API.Domain.Services; | |
namespace Supermarket.API.Controllers | |
{ | |
[Route("/api/[controller]")] | |
public class CategoriesController : Controller | |
{ | |
private readonly ICategoryService _categoryService; | |
public CategoriesController(ICategoryService categoryService) | |
{ | |
_categoryService = categoryService; | |
} | |
[HttpGet] | |
public async Task<IEnumerable<Category>> GetAllAsync() | |
{ | |
var categories = await _categoryService.ListAsync(); | |
return categories; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment