Add Blazor WebAssembly Admin Page (#426)
* Added Blazor Client Configured PublicAPI CORS to allow traffic from client * Make admin page home page; remove extra pages Add CatalogType list endpoint * Wired up Types and Brands in the API and the admin list page * Adding a custom HttpClient to talk securely to API * Ardalis/blazor (#419) * Login added * AuthService will handel http request secure and not secure. * Logout added * CatalogBrandService in it is own service * Get token from localstorage when refresh. * used GetAsync * Fixed Login and Logout switch. * CatalogItemService added * CatalogTypeService added & Auth for CatalogType. using not used removed. * Made BlazorComponent and BlazorLayoutComponent for refresh. Index now small enough to be in one file. * Removed the service from program main and use lazy singleton. * used OnInitialized * Refactoring and detecting login status in login.razor * Refactoring login to redirect if user is already logged in * Blazor login with MVC (#420) * Blazor login with MVC * return back the PasswordSignInAsync in Login page * CRUD added (#422) * CRUD added * Unit Test changed to meet new redirect /admin * CreateCatalogItemRequest added. * Action caption added. * Validation added for name and price. * Updated port of api Redirect to returnUrl from login * Add username to /admin; link to my profile * Working on authorization of /admin * Working on custom auth locking down /admin page * Microsoft authorize working.Login.razor removed.Login from SignInMana… (#425) * Microsoft authorize working.Login.razor removed.Login from SignInManager and create token from it.unit test fixed. * GetTokenFromController function used in CustomAuthStateProvider * Cleaned up button styles Refactored to use codebehind for List component Updated Not Authorized view Co-authored-by: Shady Nagy <shadynagi@gmail.com>
This commit is contained in:
8
src/PublicApi/CatalogBrandEndpoints/CatalogBrandDto.cs
Normal file
8
src/PublicApi/CatalogBrandEndpoints/CatalogBrandDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Microsoft.eShopWeb.PublicApi.CatalogBrandEndpoints
|
||||
{
|
||||
public class CatalogBrandDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.eShopWeb.PublicApi.CatalogBrandEndpoints
|
||||
{
|
||||
public class ListCatalogBrandsResponse : BaseResponse
|
||||
{
|
||||
public ListCatalogBrandsResponse(Guid correlationId) : base(correlationId)
|
||||
{
|
||||
}
|
||||
|
||||
public ListCatalogBrandsResponse()
|
||||
{
|
||||
}
|
||||
|
||||
public List<CatalogBrandDto> CatalogBrands { get; set; } = new List<CatalogBrandDto>();
|
||||
}
|
||||
}
|
||||
42
src/PublicApi/CatalogBrandEndpoints/List.cs
Normal file
42
src/PublicApi/CatalogBrandEndpoints/List.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Ardalis.ApiEndpoints;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopWeb.PublicApi.CatalogBrandEndpoints
|
||||
{
|
||||
public class List : BaseAsyncEndpoint<ListCatalogBrandsResponse>
|
||||
{
|
||||
private readonly IAsyncRepository<CatalogBrand> _catalogBrandRepository;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public List(IAsyncRepository<CatalogBrand> catalogBrandRepository,
|
||||
IMapper mapper)
|
||||
{
|
||||
_catalogBrandRepository = catalogBrandRepository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
[HttpGet("api/catalog-brands")]
|
||||
[SwaggerOperation(
|
||||
Summary = "List Catalog Brands",
|
||||
Description = "List Catalog Brands",
|
||||
OperationId = "catalog-brands.List",
|
||||
Tags = new[] { "CatalogBrandEndpoints" })
|
||||
]
|
||||
public override async Task<ActionResult<ListCatalogBrandsResponse>> HandleAsync()
|
||||
{
|
||||
var response = new ListCatalogBrandsResponse();
|
||||
|
||||
var items = await _catalogBrandRepository.ListAllAsync();
|
||||
|
||||
response.CatalogBrands.AddRange(items.Select(_mapper.Map<CatalogBrandDto>));
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user