using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using SharpSyndicationApi.Models; namespace SharpSyndicationApi.Controllers { [Route("api/[controller]")] [ApiController] public class CategoryController : ControllerBase { private readonly DataContext _context; public CategoryController(DataContext context) { _context = context; } [HttpPost] public async Task PostCategory(Category category) { _context.Categories.Add(category); await _context.SaveChangesAsync(); } [HttpGet] [ProducesResponseType(200, Type = typeof(IEnumerable))] public ActionResult>> GetCategories() { ApiResponse> response = new ApiResponse>(); IEnumerable categories = _context.Categories.ToList(); if (categories == null || !categories.Any()) return NotFound(); response.RespsonseData = categories; response.ContinuationToken = "NO_CONTINUATION"; return Ok(response); } } }