Clean up usings and controller attributes (#2124)
* Clean up usings and controller attributes - Removed redundant attributes when the controllers already specifies what the result type is. - Use StatusCodes instead of HttpStatusCode. - Clean up namespaces and use type aliases to disambiguate the many DTOs defined. * Forgot one * Update src/Services/Webhooks/Webhooks.API/Controllers/WebhooksController.cs Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com> --------- Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									c7c2d1ca2f
								
							
						
					
					
						commit
						3b9560c26e
					
				| @ -16,8 +16,7 @@ public class BasketController : ControllerBase | ||||
| 
 | ||||
|     [HttpPost] | ||||
|     [HttpPut] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(typeof(BasketData), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<ActionResult<BasketData>> UpdateAllBasketAsync([FromBody] UpdateBasketRequest data) | ||||
|     { | ||||
|         if (data.Items == null || !data.Items.Any()) | ||||
| @ -73,8 +72,7 @@ public class BasketController : ControllerBase | ||||
| 
 | ||||
|     [HttpPut] | ||||
|     [Route("items")] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(typeof(BasketData), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<ActionResult<BasketData>> UpdateQuantitiesAsync([FromBody] UpdateBasketItemsRequest data) | ||||
|     { | ||||
|         if (!data.Updates.Any()) | ||||
| @ -110,8 +108,8 @@ public class BasketController : ControllerBase | ||||
| 
 | ||||
|     [HttpPost] | ||||
|     [Route("items")] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|     public async Task<ActionResult> AddBasketItemAsync([FromBody] AddBasketItemRequest data) | ||||
|     { | ||||
|         if (data == null || data.Quantity == 0) | ||||
|  | ||||
| @ -1,11 +0,0 @@ | ||||
| namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Controllers; | ||||
| 
 | ||||
| [Route("")] | ||||
| public class HomeController : Controller | ||||
| { | ||||
|     [HttpGet] | ||||
|     public IActionResult Index() | ||||
|     { | ||||
|         return new RedirectResult("~/swagger"); | ||||
|     } | ||||
| } | ||||
| @ -16,8 +16,7 @@ public class OrderController : ControllerBase | ||||
| 
 | ||||
|     [Route("draft/{basketId}")] | ||||
|     [HttpGet] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(typeof(OrderData), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<ActionResult<OrderData>> GetOrderDraftAsync(string basketId) | ||||
|     { | ||||
|         if (string.IsNullOrEmpty(basketId)) | ||||
|  | ||||
| @ -2,12 +2,8 @@ | ||||
| global using Grpc.Core.Interceptors; | ||||
| global using Grpc.Core; | ||||
| global using GrpcBasket; | ||||
| global using HealthChecks.UI.Client; | ||||
| global using Microsoft.AspNetCore.Authentication.JwtBearer; | ||||
| global using Microsoft.AspNetCore.Authentication; | ||||
| global using Microsoft.AspNetCore.Authorization; | ||||
| global using Microsoft.AspNetCore.Builder; | ||||
| global using Microsoft.AspNetCore.Diagnostics.HealthChecks; | ||||
| global using Microsoft.AspNetCore.Http; | ||||
| global using Microsoft.AspNetCore.Mvc; | ||||
| global using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config; | ||||
| @ -16,19 +12,13 @@ global using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models; | ||||
| global using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services; | ||||
| global using Microsoft.Extensions.Configuration; | ||||
| global using Microsoft.Extensions.DependencyInjection; | ||||
| global using Microsoft.Extensions.Diagnostics.HealthChecks; | ||||
| global using Microsoft.Extensions.Logging; | ||||
| global using Microsoft.Extensions.Options; | ||||
| global using Microsoft.OpenApi.Models; | ||||
| global using System.Collections.Generic; | ||||
| global using System.IdentityModel.Tokens.Jwt; | ||||
| global using System.Linq; | ||||
| global using System.Net.Http.Headers; | ||||
| global using System.Net.Http; | ||||
| global using System.Net; | ||||
| global using System.Text.Json; | ||||
| global using System.Threading.Tasks; | ||||
| global using System.Threading; | ||||
| global using System; | ||||
| global using Microsoft.IdentityModel.Tokens; | ||||
| global using Services.Common; | ||||
|  | ||||
| @ -16,8 +16,7 @@ public class BasketController : ControllerBase | ||||
| 
 | ||||
|     [HttpPost] | ||||
|     [HttpPut] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(typeof(BasketData), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<ActionResult<BasketData>> UpdateAllBasketAsync([FromBody] UpdateBasketRequest data) | ||||
|     { | ||||
|         if (data.Items == null || !data.Items.Any()) | ||||
| @ -74,8 +73,7 @@ public class BasketController : ControllerBase | ||||
| 
 | ||||
|     [HttpPut] | ||||
|     [Route("items")] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(typeof(BasketData), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<ActionResult<BasketData>> UpdateQuantitiesAsync([FromBody] UpdateBasketItemsRequest data) | ||||
|     { | ||||
|         if (!data.Updates.Any()) | ||||
| @ -109,8 +107,8 @@ public class BasketController : ControllerBase | ||||
| 
 | ||||
|     [HttpPost] | ||||
|     [Route("items")] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|     public async Task<ActionResult> AddBasketItemAsync([FromBody] AddBasketItemRequest data) | ||||
|     { | ||||
|         if (data == null || data.Quantity == 0) | ||||
|  | ||||
| @ -16,8 +16,7 @@ public class OrderController : ControllerBase | ||||
| 
 | ||||
|     [Route("draft/{basketId}")] | ||||
|     [HttpGet] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(typeof(OrderData), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<ActionResult<OrderData>> GetOrderDraftAsync(string basketId) | ||||
|     { | ||||
|         if (string.IsNullOrWhiteSpace(basketId)) | ||||
|  | ||||
| @ -1,7 +0,0 @@ | ||||
| namespace Microsoft.eShopOnContainers.Services.Basket.API; | ||||
| 
 | ||||
| public class BasketSettings | ||||
| { | ||||
|     public string ConnectionString { get; set; } | ||||
| } | ||||
| 
 | ||||
| @ -23,7 +23,6 @@ public class BasketController : ControllerBase | ||||
|     } | ||||
| 
 | ||||
|     [HttpGet("{id}")] | ||||
|     [ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)] | ||||
|     public async Task<ActionResult<CustomerBasket>> GetBasketByIdAsync(string id) | ||||
|     { | ||||
|         var basket = await _repository.GetBasketAsync(id); | ||||
| @ -32,7 +31,6 @@ public class BasketController : ControllerBase | ||||
|     } | ||||
| 
 | ||||
|     [HttpPost] | ||||
|     [ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)] | ||||
|     public async Task<ActionResult<CustomerBasket>> UpdateBasketAsync([FromBody] CustomerBasket value) | ||||
|     { | ||||
|         return Ok(await _repository.UpdateBasketAsync(value)); | ||||
| @ -40,8 +38,8 @@ public class BasketController : ControllerBase | ||||
| 
 | ||||
|     [Route("checkout")] | ||||
|     [HttpPost] | ||||
|     [ProducesResponseType((int)HttpStatusCode.Accepted)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(StatusCodes.Status202Accepted)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<ActionResult> CheckoutAsync([FromBody] BasketCheckout basketCheckout, [FromHeader(Name = "x-requestid")] string requestId) | ||||
|     { | ||||
|         var userId = _identityService.GetUserIdentity(); | ||||
| @ -81,7 +79,7 @@ public class BasketController : ControllerBase | ||||
| 
 | ||||
|     // DELETE api/values/5 | ||||
|     [HttpDelete("{id}")] | ||||
|     [ProducesResponseType(typeof(void), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|     public async Task DeleteBasketByIdAsync(string id) | ||||
|     { | ||||
|         await _repository.DeleteBasketAsync(id); | ||||
|  | ||||
| @ -2,7 +2,6 @@ | ||||
| global using System.Collections.Generic; | ||||
| global using System.ComponentModel.DataAnnotations; | ||||
| global using System.Linq; | ||||
| global using System.Net; | ||||
| global using System.Security.Claims; | ||||
| global using System.Text.Json; | ||||
| global using System.Threading.Tasks; | ||||
|  | ||||
| @ -20,9 +20,9 @@ public class CatalogController : ControllerBase | ||||
|     // GET api/v1/[controller]/items[?pageSize=3&pageIndex=10] | ||||
|     [HttpGet] | ||||
|     [Route("items")] | ||||
|     [ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(typeof(IEnumerable<CatalogItem>), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), StatusCodes.Status200OK)] | ||||
|     [ProducesResponseType(typeof(IEnumerable<CatalogItem>), StatusCodes.Status200OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<IActionResult> ItemsAsync([FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0, string ids = null) | ||||
|     { | ||||
|         if (!string.IsNullOrEmpty(ids)) | ||||
| @ -74,9 +74,8 @@ public class CatalogController : ControllerBase | ||||
| 
 | ||||
|     [HttpGet] | ||||
|     [Route("items/{id:int}")] | ||||
|     [ProducesResponseType((int)HttpStatusCode.NotFound)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(typeof(CatalogItem), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status404NotFound)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<ActionResult<CatalogItem>> ItemByIdAsync(int id) | ||||
|     { | ||||
|         if (id <= 0) | ||||
| @ -102,7 +101,6 @@ public class CatalogController : ControllerBase | ||||
|     // GET api/v1/[controller]/items/withname/samplename[?pageSize=3&pageIndex=10] | ||||
|     [HttpGet] | ||||
|     [Route("items/withname/{name:minlength(1)}")] | ||||
|     [ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)] | ||||
|     public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsWithNameAsync(string name, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) | ||||
|     { | ||||
|         var totalItems = await _catalogContext.CatalogItems | ||||
| @ -123,7 +121,6 @@ public class CatalogController : ControllerBase | ||||
|     // GET api/v1/[controller]/items/type/1/brand[?pageSize=3&pageIndex=10] | ||||
|     [HttpGet] | ||||
|     [Route("items/type/{catalogTypeId}/brand/{catalogBrandId:int?}")] | ||||
|     [ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)] | ||||
|     public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsByTypeIdAndBrandIdAsync(int catalogTypeId, int? catalogBrandId, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) | ||||
|     { | ||||
|         var root = (IQueryable<CatalogItem>)_catalogContext.CatalogItems; | ||||
| @ -151,7 +148,6 @@ public class CatalogController : ControllerBase | ||||
|     // GET api/v1/[controller]/items/type/all/brand[?pageSize=3&pageIndex=10] | ||||
|     [HttpGet] | ||||
|     [Route("items/type/all/brand/{catalogBrandId:int?}")] | ||||
|     [ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)] | ||||
|     public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsByBrandIdAsync(int? catalogBrandId, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) | ||||
|     { | ||||
|         var root = (IQueryable<CatalogItem>)_catalogContext.CatalogItems; | ||||
| @ -177,7 +173,6 @@ public class CatalogController : ControllerBase | ||||
|     // GET api/v1/[controller]/CatalogTypes | ||||
|     [HttpGet] | ||||
|     [Route("catalogtypes")] | ||||
|     [ProducesResponseType(typeof(List<CatalogType>), (int)HttpStatusCode.OK)] | ||||
|     public async Task<ActionResult<List<CatalogType>>> CatalogTypesAsync() | ||||
|     { | ||||
|         return await _catalogContext.CatalogTypes.ToListAsync(); | ||||
| @ -186,7 +181,6 @@ public class CatalogController : ControllerBase | ||||
|     // GET api/v1/[controller]/CatalogBrands | ||||
|     [HttpGet] | ||||
|     [Route("catalogbrands")] | ||||
|     [ProducesResponseType(typeof(List<CatalogBrand>), (int)HttpStatusCode.OK)] | ||||
|     public async Task<ActionResult<List<CatalogBrand>>> CatalogBrandsAsync() | ||||
|     { | ||||
|         return await _catalogContext.CatalogBrands.ToListAsync(); | ||||
| @ -195,8 +189,8 @@ public class CatalogController : ControllerBase | ||||
|     //PUT api/v1/[controller]/items | ||||
|     [Route("items")] | ||||
|     [HttpPut] | ||||
|     [ProducesResponseType((int)HttpStatusCode.NotFound)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.Created)] | ||||
|     [ProducesResponseType(StatusCodes.Status404NotFound)] | ||||
|     [ProducesResponseType(StatusCodes.Status201Created)] | ||||
|     public async Task<ActionResult> UpdateProductAsync([FromBody] CatalogItem productToUpdate) | ||||
|     { | ||||
|         var catalogItem = await _catalogContext.CatalogItems.SingleOrDefaultAsync(i => i.Id == productToUpdate.Id); | ||||
| @ -235,7 +229,7 @@ public class CatalogController : ControllerBase | ||||
|     //POST api/v1/[controller]/items | ||||
|     [Route("items")] | ||||
|     [HttpPost] | ||||
|     [ProducesResponseType((int)HttpStatusCode.Created)] | ||||
|     [ProducesResponseType(StatusCodes.Status201Created)] | ||||
|     public async Task<ActionResult> CreateProductAsync([FromBody] CatalogItem product) | ||||
|     { | ||||
|         var item = new CatalogItem | ||||
| @ -258,8 +252,8 @@ public class CatalogController : ControllerBase | ||||
|     //DELETE api/v1/[controller]/id | ||||
|     [Route("{id}")] | ||||
|     [HttpDelete] | ||||
|     [ProducesResponseType((int)HttpStatusCode.NoContent)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.NotFound)] | ||||
|     [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||
|     [ProducesResponseType(StatusCodes.Status404NotFound)] | ||||
|     public async Task<ActionResult> DeleteProductAsync(int id) | ||||
|     { | ||||
|         var product = _catalogContext.CatalogItems.SingleOrDefault(x => x.Id == id); | ||||
|  | ||||
| @ -6,7 +6,6 @@ global using System.Globalization; | ||||
| global using System.IO; | ||||
| global using System.IO.Compression; | ||||
| global using System.Linq; | ||||
| global using System.Net; | ||||
| global using System.Text.RegularExpressions; | ||||
| global using System.Threading.Tasks; | ||||
| global using Grpc.Core; | ||||
|  | ||||
| @ -2,7 +2,6 @@ | ||||
| using static CatalogApi.Catalog; | ||||
| 
 | ||||
| namespace Microsoft.eShopOnContainers.Services.Catalog.API.Grpc; | ||||
| using Microsoft.Extensions.Logging; | ||||
| 
 | ||||
| public class CatalogService : CatalogBase | ||||
| { | ||||
|  | ||||
| @ -1,9 +1,7 @@ | ||||
| namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers; | ||||
| using CardType = Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries.CardType; | ||||
| using Order = Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries.Order; | ||||
| 
 | ||||
| using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions; | ||||
| using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands; | ||||
| using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries; | ||||
| using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services; | ||||
| namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers; | ||||
| 
 | ||||
| [Route("api/v1/[controller]")]
 | ||||
| [Authorize] | ||||
| @ -29,8 +27,8 @@ public class OrdersController : ControllerBase | ||||
| 
 | ||||
|     [Route("cancel")] | ||||
|     [HttpPut] | ||||
|     [ProducesResponseType((int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<IActionResult> CancelOrderAsync([FromBody] CancelOrderCommand command, [FromHeader(Name = "x-requestid")] string requestId) | ||||
|     { | ||||
|         bool commandResult = false; | ||||
| @ -59,8 +57,8 @@ public class OrdersController : ControllerBase | ||||
| 
 | ||||
|     [Route("ship")] | ||||
|     [HttpPut] | ||||
|     [ProducesResponseType((int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     public async Task<IActionResult> ShipOrderAsync([FromBody] ShipOrderCommand command, [FromHeader(Name = "x-requestid")] string requestId) | ||||
|     { | ||||
|         bool commandResult = false; | ||||
| @ -89,9 +87,9 @@ public class OrdersController : ControllerBase | ||||
| 
 | ||||
|     [Route("{orderId:int}")] | ||||
|     [HttpGet] | ||||
|     [ProducesResponseType(typeof(Order), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.NotFound)] | ||||
|     public async Task<ActionResult> GetOrderAsync(int orderId) | ||||
|     [ProducesResponseType(typeof(Order), StatusCodes.Status200OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status404NotFound)] | ||||
|     public async Task<ActionResult<Order>> GetOrderAsync(int orderId) | ||||
|     { | ||||
|         try | ||||
|         { | ||||
| @ -99,7 +97,7 @@ public class OrdersController : ControllerBase | ||||
|             //var order customer = await _mediator.Send(new GetOrderByIdQuery(orderId)); | ||||
|             var order = await _orderQueries.GetOrderAsync(orderId); | ||||
| 
 | ||||
|             return Ok(order); | ||||
|             return order; | ||||
|         } | ||||
|         catch | ||||
|         { | ||||
| @ -108,7 +106,7 @@ public class OrdersController : ControllerBase | ||||
|     } | ||||
| 
 | ||||
|     [HttpGet] | ||||
|     [ProducesResponseType(typeof(IEnumerable<OrderSummary>), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(typeof(IEnumerable<OrderSummary>), StatusCodes.Status200OK)] | ||||
|     public async Task<ActionResult<IEnumerable<OrderSummary>>> GetOrdersAsync() | ||||
|     { | ||||
|         var userid = _identityService.GetUserIdentity(); | ||||
| @ -119,7 +117,7 @@ public class OrdersController : ControllerBase | ||||
| 
 | ||||
|     [Route("cardtypes")] | ||||
|     [HttpGet] | ||||
|     [ProducesResponseType(typeof(IEnumerable<CardType>), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(typeof(IEnumerable<CardType>), StatusCodes.Status200OK)] | ||||
|     public async Task<ActionResult<IEnumerable<CardType>>> GetCardTypesAsync() | ||||
|     { | ||||
|         var cardTypes = await _orderQueries.GetCardTypesAsync(); | ||||
|  | ||||
| @ -1,8 +1,5 @@ | ||||
| namespace Microsoft.eShopOnContainers.Services.Ordering.API.Extensions; | ||||
| 
 | ||||
| using System.Collections.Generic; | ||||
| using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; | ||||
| 
 | ||||
| public static class BasketItemExtensions | ||||
| { | ||||
|     public static IEnumerable<OrderItemDTO> ToOrderItemsDTO(this IEnumerable<BasketItem> basketItems) | ||||
|  | ||||
| @ -4,7 +4,6 @@ global using System.Data.Common; | ||||
| global using System.Data.SqlClient; | ||||
| global using System.IO; | ||||
| global using System.Linq; | ||||
| global using System.Net; | ||||
| global using System.Runtime.Serialization; | ||||
| global using System.Threading; | ||||
| global using System.Threading.Tasks; | ||||
|  | ||||
| @ -110,10 +110,10 @@ public class OrdersWebApiTest | ||||
| 
 | ||||
|         //Act | ||||
|         var orderController = new OrdersController(_mediatorMock.Object, _orderQueriesMock.Object, _identityServiceMock.Object, _loggerMock.Object); | ||||
|         var actionResult = await orderController.GetOrderAsync(fakeOrderId) as OkObjectResult; | ||||
|         var actionResult = await orderController.GetOrderAsync(fakeOrderId); | ||||
| 
 | ||||
|         //Assert | ||||
|         Assert.Equal(actionResult.StatusCode, (int)System.Net.HttpStatusCode.OK); | ||||
|         Assert.Same(actionResult.Value, fakeDynamicResult); | ||||
|     } | ||||
| 
 | ||||
|     [Fact] | ||||
|  | ||||
| @ -17,7 +17,7 @@ public class WebhooksController : ControllerBase | ||||
| 
 | ||||
|     [Authorize] | ||||
|     [HttpGet] | ||||
|     [ProducesResponseType(typeof(IEnumerable<WebhookSubscription>), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType(typeof(IEnumerable<WebhookSubscription>), StatusCodes.Status200OK)] | ||||
|     public async Task<IActionResult> ListByUser() | ||||
|     { | ||||
|         var userId = _identityService.GetUserIdentity(); | ||||
| @ -27,8 +27,8 @@ public class WebhooksController : ControllerBase | ||||
| 
 | ||||
|     [Authorize] | ||||
|     [HttpGet("{id:int}")] | ||||
|     [ProducesResponseType(typeof(WebhookSubscription), (int)HttpStatusCode.OK)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.NotFound)] | ||||
|     [ProducesResponseType(typeof(WebhookSubscription), StatusCodes.Status200OK)] | ||||
|     [ProducesResponseType(StatusCodes.Status404NotFound)] | ||||
|     public async Task<IActionResult> GetByUserAndId(int id) | ||||
|     { | ||||
|         var userId = _identityService.GetUserIdentity(); | ||||
| @ -42,9 +42,9 @@ public class WebhooksController : ControllerBase | ||||
| 
 | ||||
|     [Authorize] | ||||
|     [HttpPost] | ||||
|     [ProducesResponseType((int)HttpStatusCode.Created)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.BadRequest)] | ||||
|     [ProducesResponseType(418)] | ||||
|     [ProducesResponseType(StatusCodes.Status201Created)] | ||||
|     [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|     [ProducesResponseType(StatusCodes.Status418ImATeapot)] | ||||
|     public async Task<IActionResult> SubscribeWebhook(WebhookSubscriptionRequest request) | ||||
|     { | ||||
|         if (!ModelState.IsValid) | ||||
| @ -71,14 +71,14 @@ public class WebhooksController : ControllerBase | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return StatusCode(418, "Grant url can't be validated"); | ||||
|             return StatusCode(StatusCodes.Status418ImATeapot, "Grant URL invalid"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     [Authorize] | ||||
|     [HttpDelete("{id:int}")] | ||||
|     [ProducesResponseType((int)HttpStatusCode.Accepted)] | ||||
|     [ProducesResponseType((int)HttpStatusCode.NotFound)] | ||||
|     [ProducesResponseType(StatusCodes.Status202Accepted)] | ||||
|     [ProducesResponseType(StatusCodes.Status404NotFound)] | ||||
|     public async Task<IActionResult> UnsubscribeWebhook(int id) | ||||
|     { | ||||
|         var userId = _identityService.GetUserIdentity(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user