-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some modifications on ExceptionHandler class. Added UpdateAsync with …
…Where expression overload . added update and delete endpoints for orders. Added IsDeleted flag on Order entity
- Loading branch information
1 parent
cf0d730
commit fa0d436
Showing
15 changed files
with
599 additions
and
38 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
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
15 changes: 15 additions & 0 deletions
15
src/Core/CleanArc.Application/Features/Order/Commands/DeleteUserOrdersCommand.Handler.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,15 @@ | ||
using CleanArc.Application.Contracts.Persistence; | ||
using CleanArc.Application.Models.Common; | ||
using Mediator; | ||
|
||
namespace CleanArc.Application.Features.Order.Commands; | ||
|
||
public class DeleteUserOrdersCommandHandler(IUnitOfWork unitOfWork) : IRequestHandler<DeleteUserOrdersCommand,OperationResult<bool>> | ||
{ | ||
public async ValueTask<OperationResult<bool>> Handle(DeleteUserOrdersCommand request, CancellationToken cancellationToken) | ||
{ | ||
await unitOfWork.OrderRepository.DeleteUserOrdersAsync(request.UserId); | ||
|
||
return OperationResult<bool>.SuccessResult(true); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/Core/CleanArc.Application/Features/Order/Commands/DeleteUserOrdersCommand.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 CleanArc.Application.Models.Common; | ||
using Mediator; | ||
|
||
namespace CleanArc.Application.Features.Order.Commands; | ||
|
||
public record DeleteUserOrdersCommand(int UserId):IRequest<OperationResult<bool>>; |
25 changes: 25 additions & 0 deletions
25
src/Core/CleanArc.Application/Features/Order/Commands/UpdateUserOrderCommand.Handler.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,25 @@ | ||
using CleanArc.Application.Contracts.Persistence; | ||
using CleanArc.Application.Models.Common; | ||
using Mediator; | ||
|
||
namespace CleanArc.Application.Features.Order.Commands; | ||
|
||
public class UpdateUserOrderCommandHandler(IUnitOfWork unitOfWork) : IRequestHandler<UpdateUserOrderCommand,OperationResult<bool>> | ||
{ | ||
|
||
|
||
public async ValueTask<OperationResult<bool>> Handle(UpdateUserOrderCommand request, CancellationToken cancellationToken) | ||
{ | ||
var order = await unitOfWork.OrderRepository.GetUserOrderByIdAndUserIdAsync(request.UserId, request.OrderId, | ||
true); | ||
|
||
if(order is null) | ||
return OperationResult<bool>.NotFoundResult("Specified Order not found"); | ||
|
||
order.OrderName=request.OrderName; | ||
|
||
await unitOfWork.CommitAsync(); | ||
|
||
return OperationResult<bool>.SuccessResult(true); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Core/CleanArc.Application/Features/Order/Commands/UpdateUserOrderCommand.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,23 @@ | ||
using System.Text.Json.Serialization; | ||
using CleanArc.Application.Models.Common; | ||
using CleanArc.SharedKernel.ValidationBase; | ||
using CleanArc.SharedKernel.ValidationBase.Contracts; | ||
using FluentValidation; | ||
using Mediator; | ||
|
||
namespace CleanArc.Application.Features.Order.Commands; | ||
|
||
public record UpdateUserOrderCommand | ||
(int OrderId, string OrderName) : IRequest<OperationResult<bool>>,IValidatableModel<UpdateUserOrderCommand> | ||
{ | ||
[JsonIgnore] | ||
public int UserId { get; set; } | ||
|
||
public IValidator<UpdateUserOrderCommand> ValidateApplicationModel(ApplicationBaseValidationModelProvider<UpdateUserOrderCommand> validator) | ||
{ | ||
validator.RuleFor(c => c.OrderId).NotEmpty().GreaterThan(0); | ||
validator.RuleFor(c => c.OrderName).NotEmpty().NotNull(); | ||
|
||
return validator; | ||
} | ||
}; |
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
Oops, something went wrong.