December 2019
Intermediate to advanced
510 pages
11h 33m
English
Action methods of controllers usually perform constraints on incoming data. A common practice is to centralize that kind of logic in filters. Let's take, for example, OrderController, which we discussed in the previous chapter:
using System;using System.Collections.Generic;using System.Linq;using Microsoft.AspNetCore.JsonPatch;using Microsoft.AspNetCore.Mvc;using SampleAPI.Filters;using SampleAPI.Models;using SampleAPI.Repositories;using SampleAPI.Requests;namespace SampleAPI.Controllers{ [Route("api/order")] [ApiController] public class OrderController : ControllerBase { private readonly IOrderRepository _orderRepository; public OrderController(IOrderRepository ordersRepository) { _orderRepository = ordersRepository; ...