forked from engindemirog/nArchitecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68877c4
commit 6a7e297
Showing
5 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/demoProjects/rentACar/Application/Features/Brands/Dtos/BrandListDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Application.Features.Brands.Dtos | ||
{ | ||
public class BrandListDto | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/demoProjects/rentACar/Application/Features/Brands/Models/BrandListModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Application.Features.Brands.Dtos; | ||
using Core.Persistence.Paging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Application.Features.Brands.Models | ||
{ | ||
public class BrandListModel:BasePageableModel | ||
{ | ||
public IList<BrandListDto> Items { get; set; } | ||
|
||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...moProjects/rentACar/Application/Features/Brands/Queries/GetListBrand/GetListBrandQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Application.Features.Brands.Models; | ||
using Application.Services.Repositories; | ||
using AutoMapper; | ||
using Core.Application.Requests; | ||
using Core.Persistence.Paging; | ||
using Domain.Entities; | ||
using MediatR; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Application.Features.Brands.Queries.GetListBrand | ||
{ | ||
public class GetListBrandQuery:IRequest<BrandListModel> | ||
{ | ||
public PageRequest PageRequest { get; set; } | ||
public class GetListBrandQueryHandler : IRequestHandler<GetListBrandQuery, BrandListModel> | ||
{ | ||
private readonly IBrandRepository _brandRepository; | ||
private readonly IMapper _mapper; | ||
|
||
public GetListBrandQueryHandler(IBrandRepository brandRepository, IMapper mapper) | ||
{ | ||
_brandRepository = brandRepository; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task<BrandListModel> Handle(GetListBrandQuery request, CancellationToken cancellationToken) | ||
{ | ||
IPaginate<Brand> brands = await _brandRepository.GetListAsync(index: request.PageRequest.Page,size:request.PageRequest.PageSize); | ||
|
||
BrandListModel mappedBrandListModel = _mapper.Map<BrandListModel>(brands); | ||
|
||
return mappedBrandListModel; | ||
} | ||
} | ||
} | ||
|
||
//22.05 Dersteyiz... | ||
} |