Skip to content

Instantly share code, notes, and snippets.

@evgomes
Last active February 24, 2019 15:33
Show Gist options
  • Save evgomes/1c82c93ad1d58694afebea87afa01113 to your computer and use it in GitHub Desktop.
Save evgomes/1c82c93ad1d58694afebea87afa01113 to your computer and use it in GitHub Desktop.
CategoriesController after creating ICategoryService and first HTTP GET, from Supermarket API.
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