public void UpdateItem(RoomViewForCartModel sp, int quantity) { CartItem line = lineCollection .Where(p => p.Room.Id_Room == sp.Id_Room) .FirstOrDefault(); if (line != null) { if (quantity > 0) { line.Quantity = quantity; } else { lineCollection.RemoveAll(l => l.Room.Id_Room == sp.Id_Room); } } }
public void AddItem(RoomViewForCartModel sp, int quantity) { CartItem line = lineCollection .Where(p => p.Room.Id_Room == sp.Id_Room) .FirstOrDefault(); if (line == null) { lineCollection.Add(new CartItem { Room = sp, Quantity = quantity }); } else { line.Quantity += quantity; if (line.Quantity <= 0) { lineCollection.RemoveAll(l => l.Room.Id_Room == sp.Id_Room); } } }
public void RemoveLine(RoomViewForCartModel sp) { lineCollection.RemoveAll(l => l.Room.Id_Room == sp.Id_Room); }