-
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.
Merge pull request #21 from ilyasbozdemir/case-project
Add report loss, damage, and renew book commands
- Loading branch information
Showing
33 changed files
with
1,410 additions
and
476 deletions.
There are no files selected for viewing
16 changes: 8 additions & 8 deletions
16
...Application/Features/BorrowLend/Behaviors/Validator/GetAllBorrowsQueryRequestValidator.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,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Queries.Requests; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Behaviors.Validator | ||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Behaviors.Validator; | ||
|
||
|
||
public class GetAllBorrowsQueryRequestValidator : AbstractValidator<GetAllBorrowsQueryRequest> | ||
{ | ||
internal class GetAllBorrowsQueryRequestValidator | ||
public GetAllBorrowsQueryRequestValidator() | ||
{ | ||
|
||
} | ||
} | ||
} |
12 changes: 7 additions & 5 deletions
12
...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,12 +1,14 @@ | ||
using System; | ||
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 | ||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Behaviors.Validator; | ||
|
||
|
||
public class GetBorrowByIdQueryRequestValidator : AbstractValidator<GetBorrowByIdQueryRequest> | ||
{ | ||
internal class GetBorrowByIdQueryRequestValidator | ||
{ | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...Application/Features/BorrowLend/Behaviors/Validator/RenewBorrowCommandRequestValidator.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 LibraryTrackingApp.Application.Features.BorrowLend.Commands.Requests; | ||
|
||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Behaviors.Validator; | ||
|
||
|
||
public class RenewBorrowCommandRequestValidator : AbstractValidator<RenewBorrowCommandRequest> | ||
{ | ||
public RenewBorrowCommandRequestValidator() | ||
{ | ||
RuleFor(x => x.BorrowId).NotEmpty().WithMessage("BorrowId boş olamaz."); | ||
RuleFor(x => x.RenewalDurationInDays).NotEmpty().GreaterThan(0).WithMessage("Yenileme süresi boş olamaz ve 0'dan büyük olmalıdır."); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...cation/Features/BorrowLend/Behaviors/Validator/ReportDamageBookCommandRequestValidator.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,13 @@ | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Requests; | ||
|
||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Behaviors.Validator; | ||
|
||
public class ReportDamageBookCommandRequestValidator : AbstractValidator<ReportDamageBookCommandRequest> | ||
{ | ||
public ReportDamageBookCommandRequestValidator() | ||
{ | ||
RuleFor(x => x.BorrowId).NotEmpty().WithMessage("BorrowId boş olamaz."); | ||
RuleFor(x => x.DamageDescription).NotEmpty().WithMessage("Hasar açıklaması boş olamaz."); | ||
} | ||
} |
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
46 changes: 46 additions & 0 deletions
46
...rackingApp.Application/Features/BorrowLend/Commands/Handlers/RenewBorrowCommandHandler.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,46 @@ | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Requests; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Responses; | ||
using LibraryTrackingApp.Application.Interfaces.UnitOfWork; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Commands.Handlers; | ||
|
||
public class RenewBorrowCommandHandler | ||
: IRequestHandler<RenewBorrowCommandRequest, RenewBorrowCommandResponse> | ||
{ | ||
private readonly IUnitOfWork<Guid> _unitOfWork; | ||
private readonly IMediator _mediator; | ||
private readonly IMapper _mapper; | ||
|
||
public RenewBorrowCommandHandler( | ||
IUnitOfWork<Guid> unitOfWork, | ||
IMapper mapper, | ||
IMediator mediator | ||
) | ||
{ | ||
_unitOfWork = unitOfWork; | ||
_mediator = mediator; | ||
_mapper = mapper; | ||
} | ||
|
||
//yazılcak daha burası | ||
|
||
public async Task<RenewBorrowCommandResponse> Handle( | ||
RenewBorrowCommandRequest request, | ||
CancellationToken cancellationToken | ||
) | ||
{ | ||
try | ||
{ | ||
return new() { }; | ||
} | ||
catch (Exception ex) | ||
{ | ||
return new() | ||
{ | ||
StatusCode = 500, | ||
Success = false, | ||
StateMessages = new[] { $"Bir hata oluştu: {ex.Message}" } | ||
}; | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...ngApp.Application/Features/BorrowLend/Commands/Handlers/ReportDamageBookCommandHandler.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,39 @@ | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Requests; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Responses; | ||
using LibraryTrackingApp.Application.Interfaces.UnitOfWork; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Commands.Handlers; | ||
|
||
public class ReportDamageBookCommandHandler | ||
: IRequestHandler<ReportDamageBookCommandRequest, ReportDamageBookCommandResponse> | ||
{ | ||
private readonly IUnitOfWork<Guid> _unitOfWork; | ||
private readonly IMediator _mediator; | ||
private readonly IMapper _mapper; | ||
|
||
public ReportDamageBookCommandHandler( | ||
IUnitOfWork<Guid> unitOfWork, | ||
IMapper mapper, | ||
IMediator mediator | ||
) | ||
{ | ||
_unitOfWork = unitOfWork; | ||
_mediator = mediator; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task<ReportDamageBookCommandResponse> Handle( | ||
ReportDamageBookCommandRequest request, | ||
CancellationToken cancellationToken | ||
) | ||
{ | ||
var response = new ReportDamageBookCommandResponse | ||
{ | ||
StatusCode = 200, | ||
Success = true, | ||
StateMessages = new string[] { "Hasar raporu başarıyla oluşturuldu." } | ||
}; | ||
|
||
return response; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...kingApp.Application/Features/BorrowLend/Commands/Handlers/ReportLossBookCommandHandler.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,44 @@ | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Requests; | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Responses; | ||
using LibraryTrackingApp.Application.Interfaces.UnitOfWork; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Commands.Handlers; | ||
|
||
public class ReportLossBookCommandHandler | ||
: IRequestHandler<ReportLossBookCommandRequest, ReportLossBookCommandResponse> | ||
{ | ||
private readonly IUnitOfWork<Guid> _unitOfWork; | ||
private readonly IMediator _mediator; | ||
private readonly IMapper _mapper; | ||
|
||
public ReportLossBookCommandHandler( | ||
IUnitOfWork<Guid> unitOfWork, | ||
IMapper mapper, | ||
IMediator mediator | ||
) | ||
{ | ||
_unitOfWork = unitOfWork; | ||
_mediator = mediator; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task<ReportLossBookCommandResponse> Handle( | ||
ReportLossBookCommandRequest request, | ||
CancellationToken cancellationToken | ||
) | ||
{ | ||
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
9 changes: 9 additions & 0 deletions
9
...rackingApp.Application/Features/BorrowLend/Commands/Requests/RenewBorrowCommandRequest.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,9 @@ | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Responses; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Commands.Requests; | ||
|
||
public class RenewBorrowCommandRequest : IRequest<RenewBorrowCommandResponse> | ||
{ | ||
public Guid BorrowId { get; set; } | ||
public int RenewalDurationInDays { get; set; } | ||
} |
10 changes: 10 additions & 0 deletions
10
...ngApp.Application/Features/BorrowLend/Commands/Requests/ReportDamageBookCommandRequest.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,10 @@ | ||
| ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Responses; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Commands.Requests; | ||
|
||
public class ReportDamageBookCommandRequest : IRequest<ReportDamageBookCommandResponse> | ||
{ | ||
public Guid BorrowId { get; set; } | ||
public string DamageDescription { get; set; } | ||
} |
8 changes: 8 additions & 0 deletions
8
...kingApp.Application/Features/BorrowLend/Commands/Requests/ReportLossBookCommandRequest.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,8 @@ | ||
using LibraryTrackingApp.Application.Features.BorrowLend.Commands.Responses; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Commands.Requests; | ||
|
||
public class ReportLossBookCommandRequest : IRequest<ReportLossBookCommandResponse> | ||
{ | ||
public Guid BookId { get; set; } | ||
} |
6 changes: 6 additions & 0 deletions
6
...ckingApp.Application/Features/BorrowLend/Commands/Responses/RenewBorrowCommandResponse.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,6 @@ | ||
using LibraryTrackingApp.Application.Shared.Wrappers.Results; | ||
|
||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Commands.Responses; | ||
|
||
public class RenewBorrowCommandResponse : CommandResult { } |
4 changes: 4 additions & 0 deletions
4
...App.Application/Features/BorrowLend/Commands/Responses/ReportDamageBookCommandResponse.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,4 @@ | ||
using LibraryTrackingApp.Application.Shared.Wrappers.Results; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Commands.Responses; | ||
public class ReportDamageBookCommandResponse : CommandResult { } |
4 changes: 4 additions & 0 deletions
4
...ngApp.Application/Features/BorrowLend/Commands/Responses/ReportLossBookCommandResponse.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,4 @@ | ||
using LibraryTrackingApp.Application.Shared.Wrappers.Results; | ||
|
||
namespace LibraryTrackingApp.Application.Features.BorrowLend.Commands.Responses; | ||
public class ReportLossBookCommandResponse : CommandResult { } |
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
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
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
20 changes: 20 additions & 0 deletions
20
LibraryTrackingApp/src/backend/Core/LibraryTrackingApp.Domain/Entities/Library/BookEntry.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,20 @@ | ||
namespace LibraryTrackingApp.Domain.Entities.Library; | ||
|
||
|
||
//bookstock tablosu kalkıcaktır. stokları teker teker aynı kitapta da verilen numaralar ile ayırarak burda da bunu girerek | ||
// yapılcaktır stok adedi bu şekilde olucaktır. | ||
public class BookEntry : BaseEntity<Guid>, IAuditable<Guid> | ||
{ | ||
public Guid Id { get; set; } | ||
public Guid BookId { get; set; } | ||
public string BookNumber { get; set; } | ||
public BookStatus BookStatus { get; set; } | ||
public BookFormat BookFormat { get; set; } | ||
public BookLanguage BookLanguage { get; set; } | ||
public bool IsAvailable { get; set; } | ||
|
||
public DateTime EntryDate { get; set; } | ||
public DateTime LastModified { get; set; } | ||
|
||
public Book Book { 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
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
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 |
---|---|---|
|
@@ -4,6 +4,9 @@ public enum BorrowLendType | |
{ | ||
Taken, | ||
Given, | ||
Renewed, | ||
Damaged, | ||
Lost, | ||
FetchedSingle, | ||
FetchedAll, | ||
} |
Oops, something went wrong.