Skip to content

Commit

Permalink
Fix updating order
Browse files Browse the repository at this point in the history
  • Loading branch information
blaz-cerpnjak committed Apr 14, 2024
1 parent d09419c commit 94d7763
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion API_GatewayWeb/HTTP_API/Order.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ func (a *Controller) updateOrder(ctx *gin.Context) {
return
}

confirmation, err := a.logic.UpdateOrder(ctx.Request.Context(), id)
var order DataStructures.Order
err = ctx.BindJSON(&order)
if err != nil {
ctx.JSON(400, gin.H{"error": err.Error()})
return
}

confirmation, err := a.logic.UpdateOrder(ctx.Request.Context(), id, order)
if err != nil {
ctx.JSON(500, gin.H{"error": err.Error()})
return
Expand Down
7 changes: 5 additions & 2 deletions API_GatewayWeb/Logic/Order.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ func (c *Controller) CreateOrder(ctx context.Context, order DataStructures.Order
return
}

func (c *Controller) UpdateOrder(ctx context.Context, id primitive.ObjectID) (confirmation *pb.Confirmation, err error) {
confirmation, err = c.grpc.Client.UpdateOrder(ctx, &pb.Order{Id: id.Hex()})
func (c *Controller) UpdateOrder(ctx context.Context, id primitive.ObjectID, order DataStructures.Order) (confirmation *pb.Confirmation, err error) {

orderGrpc := Converter.ConvertOrderToGrpc(order)

confirmation, err = c.grpc.Client.UpdateOrder(ctx, orderGrpc)
if err != nil {
fmt.Println(err.Error())
return
Expand Down

0 comments on commit 94d7763

Please sign in to comment.