December 2019
Intermediate to advanced
510 pages
11h 33m
English
We have already dealt with action methods in Chapter 5, Web Service Stack in ASP.NET Core. In the following implementation, we will use the IItemService interface in the action methods, as follows:
using System;using System.Threading.Tasks;using Catalog.Domain.Requests.Item;using Catalog.Domain.Services;using Microsoft.AspNetCore.Mvc;namespace Catalog.API.Controllers{ [Route("api/items")] [ApiController] public class ItemController : ControllerBase { private readonly IItemService _itemService; public ItemController(IItemService itemService) { _itemService = itemService; } [HttpGet] public async Task<IActionResult> Get() { var result = await _itemService.GetItemsAsync(); return Ok(result); } [HttpGet("{id:guid}" ...