Merge branch 'feature/pubsub' of git-ssh.tornberg.me:mats/go-cart-actor into feature/pubsub
This commit is contained in:
@@ -48,8 +48,15 @@ func (c *CartMutationContext) ChangeQuantity(g *CartGrain, m *messages.ChangeQua
|
||||
g.UpdateTotals()
|
||||
return nil
|
||||
}
|
||||
|
||||
g.Items[foundIndex].Quantity = int(m.Quantity)
|
||||
g.UpdateTotals()
|
||||
item := g.Items[foundIndex]
|
||||
if item == nil {
|
||||
return fmt.Errorf("ChangeQuantity: item id %d not found", m.Id)
|
||||
}
|
||||
if item.ReservationEndTime != nil {
|
||||
return fmt.Errorf("ChangeQuantity: cannot change quantity of reserved item id %d", m.Id)
|
||||
} else {
|
||||
item.Quantity = int(m.Quantity)
|
||||
g.UpdateTotals()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user