Co-authored-by: matst80 <mats.tornberg@gmail.com> Reviewed-on: #8 Co-authored-by: Mats Törnberg <mats@tornberg.me> Co-committed-by: Mats Törnberg <mats@tornberg.me>
21 lines
462 B
Go
21 lines
462 B
Go
package cart
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
messages "git.k6n.net/go-cart-actor/proto/cart"
|
|
)
|
|
|
|
func SubscriptionAdded(grain *CartGrain, req *messages.SubscriptionAdded) error {
|
|
|
|
for i, item := range grain.Items {
|
|
if item.Id == req.ItemId {
|
|
grain.Items[i].SubscriptionDetailsId = req.DetailsId
|
|
grain.Items[i].OrderReference = req.OrderReference
|
|
grain.Items[i].IsSubscribed = true
|
|
return nil
|
|
}
|
|
}
|
|
return fmt.Errorf("item with ID %d not found", req.ItemId)
|
|
}
|