Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added subCategories command #65

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CategoriesController(IMediator mediator) : ControllerBase

[HttpGet("links")]
[Authorize(Roles = "admin")]
public async Task<ActionResult<IEnumerable<DefaultLinkDto>>> GetCategoriesDefaultLinks(
public async Task<ActionResult<IEnumerable<DefaultLinkDTO>>> GetCategoriesDefaultLinks(
[FromQuery] string? search,
CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Mint.Domain.Helpers;
using Mint.WebApp.Admin.Operations.Commands.SubCategories;
using Mint.WebApp.Admin.Operations.Dtos.SubCategories;

namespace Mint.WebApp.Admin.Controllers;

[ApiController]
[Route("api/[controller]")]
public class SubCategoriesController(IMediator mediator) : ControllerBase
{
[HttpGet]
public async Task<ActionResult<PaginatedResult<SubCategoryDTO>>> Get(
[FromQuery] GetSubCategoriesCommand command,
CancellationToken cancellationToken = default)
{
return await mediator.Send(command, cancellationToken);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@

namespace Mint.WebApp.Admin.Operations.Commands.Categories;

public sealed record GetCategoriesDefaultLinksCommand(string? Search) : ICommand<IEnumerable<DefaultLinkDto>>;
public sealed record GetCategoriesDefaultLinksCommand(string? Search) : ICommand<IEnumerable<DefaultLinkDTO>>;

internal sealed class GetCategoriesDefaultLinksCommandHandler(
IMapper mapper,
ICategoryRepository categoryRepository
) : ICommandHandler<GetCategoriesDefaultLinksCommand, IEnumerable<DefaultLinkDto>>
) : ICommandHandler<GetCategoriesDefaultLinksCommand, IEnumerable<DefaultLinkDTO>>
{
private readonly IMapper _mapper = mapper;
private readonly ICategoryRepository _categoryRepository = categoryRepository;

public async Task<IEnumerable<DefaultLinkDto>> Handle(GetCategoriesDefaultLinksCommand request, CancellationToken cancellationToken)
public async Task<IEnumerable<DefaultLinkDTO>> Handle(GetCategoriesDefaultLinksCommand request, CancellationToken cancellationToken)
{
var categories = await _categoryRepository.GetCategoriesLinkAsync(request.Search, cancellationToken);

return _mapper.Map<IEnumerable<DefaultLinkDto>>(categories);
return _mapper.Map<IEnumerable<DefaultLinkDTO>>(categories);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Mint.Domain.Helpers;
using Mint.Infrastructure.MessageBrokers.Interfaces;
using Mint.WebApp.Admin.Operations.Dtos.SubCategories;

namespace Mint.WebApp.Admin.Operations.Commands.SubCategories;

public sealed record GetSubCategoriesCommand(
string? Search,
int PageIndex = 0,
int PageSize = 50
) : ICommand<PaginatedResult<SubCategoryDTO>>;

internal sealed class GetSubCategoriesCommandHandler
: ICommandHandler<GetSubCategoriesCommand, PaginatedResult<SubCategoryDTO>>
{
public Task<PaginatedResult<SubCategoryDTO>> Handle(GetSubCategoriesCommand request, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Mint.WebApp.Admin.Operations.Dtos.Categories;

public class DefaultLinkDto
public class DefaultLinkDTO
{
public Guid Id { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Mint.WebApp.Admin.Operations.Dtos.SubCategories;

public class SubCategoryDTO
{
}
2 changes: 1 addition & 1 deletion src/modules/Admin/Mint.WebApp.Admin/Utils/AdminMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AdminMapper : Profile
{
public AdminMapper()
{
CreateMap<Category, DefaultLinkDto>();
CreateMap<Category, DefaultLinkDTO>();
CreateMap<Category, CategoryFullViewModel>();

CreateMap<SubCategory, SubCategoryFullViewModel>();
Expand Down
Loading