-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bumped Eventuous version to b10, applied associated fixes * removed "with ID" command/event * added use cases for Cart; partial impl
- Loading branch information
1 parent
9977081
commit 04fac49
Showing
14 changed files
with
81 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
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 |
---|---|---|
@@ -1,49 +1,57 @@ | ||
using Eventuous; | ||
using Eventuous.AspNetCore.Web; | ||
using Microsoft.AspNetCore.Mvc; | ||
using static ShoppingCart.CartCommands.V1; | ||
|
||
namespace ShoppingCart.Api.HttpApi; | ||
|
||
[Route("/cart")] | ||
public class CommandApi(IFuncCommandService<CartState> service) : ControllerBase | ||
public class CommandApi : CommandHttpApiBaseFunc<CartState> | ||
{ | ||
[HttpPost] | ||
[Route("open")] | ||
public async Task<ActionResult<Result>> OpenCart([FromBody] OpenCart cmd, CancellationToken ct) | ||
private readonly IFuncCommandService<CartState> _service; | ||
|
||
public CommandApi(IFuncCommandService<CartState> service) : base(service) | ||
{ | ||
var result = await service.Handle(cmd, ct); | ||
return Ok(result); | ||
_service = service; | ||
} | ||
|
||
[HttpPost] | ||
[Route("open-with-id")] | ||
public async Task<ActionResult<Result>> OpenCart([FromBody] OpenCartWithProvidedId cmd, CancellationToken ct) | ||
[Route("open")] | ||
public async Task<ActionResult<Result>> OpenCart([FromBody] OpenCart cmd, CancellationToken ct) | ||
{ | ||
var result = await service.Handle(cmd, ct); | ||
var result = await _service.Handle(cmd, ct); | ||
return Ok(result); | ||
} | ||
|
||
[HttpPost] | ||
[Route("add-product")] | ||
public async Task<ActionResult<Result>> OpenCart([FromBody] AddProductToCart cmd, CancellationToken ct) | ||
{ | ||
var result = await service.Handle(cmd, ct); | ||
var result = await _service.Handle(cmd, ct); | ||
return Ok(result); | ||
} | ||
|
||
[HttpPost] | ||
[Route("remove-product")] | ||
public async Task<ActionResult<Result>> OpenCart([FromBody] RemoveProductFromCart cmd, CancellationToken ct) | ||
{ | ||
var result = await service.Handle(cmd, ct); | ||
var result = await _service.Handle(cmd, ct); | ||
return Ok(result); | ||
} | ||
|
||
[HttpPost] | ||
[Route("prepare-checkout")] | ||
public async Task<ActionResult<Result>> PrepareForCheckout([FromBody] PrepareCartForCheckout cmd, CancellationToken ct) | ||
{ | ||
var result = await _service.Handle(cmd, ct); | ||
return Ok(result); | ||
} | ||
|
||
[HttpPost] | ||
[Route("confirm")] | ||
public async Task<ActionResult<Result>> OpenCart([FromBody] ConfirmCart cmd, CancellationToken ct) | ||
{ | ||
var result = await service.Handle(cmd, ct); | ||
var result = await _service.Handle(cmd, ct); | ||
return Ok(result); | ||
} | ||
} |
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
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