public Products RedeemKalamataTicket(KalamataTicket Ticket) { StorageItem myItem = ItemsStored.Find(x => x.ReserveID == Ticket.ReservationID); ItemsStored.Remove(myItem); return(myItem.Product); }
public List <KalamataTicket> GetTicketForProducts(ref List <Products> products) { List <KalamataTicket> tickets = new List <KalamataTicket>(); // only loop the usually larger list once. foreach (StorageItem item in ItemsStored) { // if the item isn't reserved then continue tests on it. if (!item.Reserved) { // this usuially being the smaller list gets looped more often. foreach (Products product in products) { // if the product is the one we want, create a ticket for it and remove it from the critea. if (product == item.Product) { KalamataTicket nTicket = new KalamataTicket(product, this, item.ReserveProduct()); tickets.Add(nTicket); products.Remove(product); break; } } } if (products.Count == 0) { break; } } return(tickets); }