-
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.
feat: Implement GetAllBorrowsQuery feature
- Added GetAllBorrowsQueryRequest, GetAllBorrowsQueryRequestValidator, GetAllBorrowsQueryResponse, and GetAllBorrowsQueryHandler classes - GetAllBorrowsQueryHandler retrieves all borrow lends using IUnitOfWork and maps them to BorrowLendDTO - Returns response with borrow lends or appropriate error message
- Loading branch information
1 parent
15e5793
commit 745092b
Showing
10 changed files
with
200 additions
and
73 deletions.
There are no files selected for viewing
32 changes: 30 additions & 2 deletions
32
...ackingApp.Application/Features/BookStocks/Queries/Handlers/GetAllBookStockQueryHandler.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 |
---|---|---|
@@ -1,12 +1,40 @@ | ||
using LibraryTrackingApp.Application.Features.BookStocks.Queries.Requests; | ||
using LibraryTrackingApp.Application.Features.BookStocks.Queries.Responses; | ||
using LibraryTrackingApp.Application.Interfaces.UnitOfWork; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BookStocks.Queries.Handlers; | ||
|
||
public class GetAllBookStocksQueryHandler : IRequestHandler<GetAllBookStockQueryRequest, GetAllBookStockQueryResponse> | ||
{ | ||
public Task<GetAllBookStockQueryResponse> Handle(GetAllBookStockQueryRequest request, CancellationToken cancellationToken) | ||
private readonly IUnitOfWork<Guid> _unitOfWork; | ||
private readonly IMediator _mediator; | ||
private readonly IMapper _mapper; | ||
|
||
public GetAllBookStocksQueryHandler( | ||
IUnitOfWork<Guid> unitOfWork, | ||
IMapper mapper, | ||
IMediator mediator | ||
) | ||
{ | ||
_unitOfWork = unitOfWork; | ||
_mediator = mediator; | ||
_mapper = mapper; | ||
} | ||
public async Task<GetAllBookStockQueryResponse> Handle(GetAllBookStockQueryRequest request, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); | ||
try | ||
{ | ||
return new() { }; | ||
} | ||
catch (Exception ex) | ||
{ | ||
return new() | ||
{ | ||
StatusCode = 500, | ||
Success = false, | ||
StateMessages = new[] { $"Bir hata oluştu: {ex.Message}" } | ||
|
||
}; | ||
} | ||
} | ||
} |
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
10 changes: 4 additions & 6 deletions
10
...Application/Features/BorrowLend/Behaviors/Validator/GetBorrowByIdQueryRequestValidator.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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Queries.Requests; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Behaviors.Validator; | ||
|
||
|
||
public class GetBorrowByIdQueryRequestValidator : AbstractValidator<GetBorrowByIdQueryRequest> | ||
{ | ||
|
||
public GetBorrowByIdQueryRequestValidator() | ||
{ | ||
RuleFor(x => x.BorrowId).NotEmpty().WithMessage("BorrowId Boş Olamaz"); | ||
} | ||
} |
45 changes: 37 additions & 8 deletions
45
...TrackingApp.Application/Features/BorrowLend/Queries/Handlers/GetAllBorrowsQueryHandler.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 |
---|---|---|
@@ -1,12 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Queries.Requests; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Queries.Responses; | ||
using LibraryTrackingApp.Application.Interfaces.UnitOfWork; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Handlers | ||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Handlers; | ||
|
||
public class GetAllBorrowsQueryHandler : IRequestHandler<GetAllBorrowsQueryRequest, GetAllBorrowsQueryResponse> | ||
{ | ||
internal class GetAllBorrowsQueryHandler | ||
private readonly IUnitOfWork<Guid> _unitOfWork; | ||
private readonly IMediator _mediator; | ||
private readonly IMapper _mapper; | ||
|
||
public GetAllBorrowsQueryHandler( | ||
IUnitOfWork<Guid> unitOfWork, | ||
IMapper mapper, | ||
IMediator mediator | ||
) | ||
{ | ||
_unitOfWork = unitOfWork; | ||
_mediator = mediator; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task<GetAllBorrowsQueryResponse> Handle(GetAllBorrowsQueryRequest request, CancellationToken cancellationToken) | ||
{ | ||
try | ||
{ | ||
return new() { }; | ||
} | ||
catch (Exception ex) | ||
{ | ||
return new() | ||
{ | ||
StatusCode = 500, | ||
Success = false, | ||
StateMessages = new[] { $"Bir hata oluştu: {ex.Message}" } | ||
|
||
}; | ||
} | ||
} | ||
} | ||
} |
46 changes: 38 additions & 8 deletions
46
...TrackingApp.Application/Features/BorrowLend/Queries/Handlers/GetBorrowByIdQueryHandler.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 |
---|---|---|
@@ -1,12 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Queries.Requests; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Queries.Responses; | ||
using LibraryTrackingApp.Application.Interfaces.UnitOfWork; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Handlers | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Handlers; | ||
|
||
public class GetBorrowByIdQueryHandler : IRequestHandler<GetBorrowByIdQueryRequest, GetBorrowByIdQueryResponse> | ||
{ | ||
internal class GetBorrowByIdQueryHandler | ||
private readonly IUnitOfWork<Guid> _unitOfWork; | ||
private readonly IMediator _mediator; | ||
private readonly IMapper _mapper; | ||
|
||
public GetBorrowByIdQueryHandler( | ||
IUnitOfWork<Guid> unitOfWork, | ||
IMapper mapper, | ||
IMediator mediator | ||
) | ||
{ | ||
_unitOfWork = unitOfWork; | ||
_mediator = mediator; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task<GetBorrowByIdQueryResponse> Handle(GetBorrowByIdQueryRequest request, CancellationToken cancellationToken) | ||
{ | ||
try | ||
{ | ||
return new() { }; | ||
} | ||
catch (Exception ex) | ||
{ | ||
return new() | ||
{ | ||
StatusCode = 500, | ||
Success = false, | ||
StateMessages = new[] { $"Bir hata oluştu: {ex.Message}" } | ||
|
||
}; | ||
} | ||
} | ||
} | ||
} |
17 changes: 7 additions & 10 deletions
17
...TrackingApp.Application/Features/BorrowLend/Queries/Requests/GetAllBorrowsQueryRequest.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 |
---|---|---|
@@ -1,12 +1,9 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Queries.Responses; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Requests | ||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Requests; | ||
|
||
public class GetAllBorrowsQueryRequest:IRequest<GetAllBorrowsQueryResponse> | ||
{ | ||
public class GetAllBorrowsQueryRequest | ||
{ | ||
} | ||
} | ||
public int PageSize { get; set; } | ||
public int PageIndex { get; set; } | ||
} |
14 changes: 5 additions & 9 deletions
14
...TrackingApp.Application/Features/BorrowLend/Queries/Requests/GetBorrowByIdQueryRequest.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 |
---|---|---|
@@ -1,12 +1,8 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Queries.Responses; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Requests | ||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Requests; | ||
|
||
public class GetBorrowByIdQueryRequest:IRequest<GetBorrowByIdQueryResponse> | ||
{ | ||
public class GetBorrowByIdQueryRequest | ||
{ | ||
} | ||
public Guid BorrowId { get; set; } | ||
} |
16 changes: 6 additions & 10 deletions
16
...ackingApp.Application/Features/BorrowLend/Queries/Responses/GetAllBorrowsQueryResponse.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 |
---|---|---|
@@ -1,12 +1,8 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using LibraryTrackingApp.Application.Shared.Wrappers.Results; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Responses | ||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Responses; | ||
|
||
public class GetAllBorrowsQueryResponse : PaginatedQueryResult<BorrowLendDTO> | ||
{ | ||
internal class GetAllBorrowsQueryResponse | ||
{ | ||
} | ||
} | ||
|
||
} |
16 changes: 6 additions & 10 deletions
16
...ackingApp.Application/Features/BorrowLend/Queries/Responses/GetBorrowByIdQueryResponse.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 |
---|---|---|
@@ -1,12 +1,8 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using LibraryTrackingApp.Application.Shared.Wrappers.Results; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Responses | ||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Queries.Responses; | ||
|
||
public class GetBorrowByIdQueryResponse:QueryResult<BorrowLendDTO> | ||
{ | ||
internal class GetBorrowByIdQueryResponse | ||
{ | ||
} | ||
} | ||
|
||
} |
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