public void Scan(string sku) { // Check that the scanned item is available for purchase. var item = AllItems.FirstOrDefault(x => x.Sku == sku); if (item == null) { Logger.Log("An invalid item was scanned."); throw new InvalidBarcodeException("Invalid item"); } // Add the item to the basket. if (!ShoppingBasket.ContainsKey(item)) { ShoppingBasket.Add(item, 1); Logger.Log($"A new item {item.Sku} was added. Total price: {TotalPrice}"); } else { ShoppingBasket[item]++; Logger.Log($"Quantity of {item.Sku} is now {ShoppingBasket[item]}."); } TotalPrice += item.UnitPrice; }
private void PlayCmd(long mediaItemId) { var mediaItem = AllItems.FirstOrDefault(item => item.Id == mediaItemId); if (mediaItem != null) { Process.Start(mediaItem.Path); } }
public ITestObject FindFirst(Func <ITestObject, bool> func, bool recursive = true) { if (!recursive) { return(_testObjects.Values.FirstOrDefault(func)); } //recursive return(AllItems.FirstOrDefault(func)); }
private async void UserControl_Loaded(object sender, RoutedEventArgs e) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { AllItems = await Service.GetNavigationItems(); Home = AllItems.FirstOrDefault(ni => ni.IsRoot).Id; btnHome_Click(null, null); }); }
public async Task UpdatePlayerStats(bool updateInventory) { if (!updateInventory && AllItems != null) { InventoryItem item = AllItems.FirstOrDefault( x => x.InventoryItemData.PlayerStats != null); //Saves for viewing Stats = item.InventoryItemData.PlayerStats; } else { await GetInventory(); } }
/// <summary> /// this overload function only search object using control properties /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <param name="recursive"></param> /// <returns></returns> public ITestObject FindFirst(string key, string value, bool recursive = true) { //NodeName is not in properties list if (key == DescriptorKeys.NodeName) { return(FindFirst(obj => obj.NodeName == value, recursive)); } if (!recursive) { return(_testObjects.Values.FirstOrDefault(o => o.Contains(key) && o[key] == value)); } //recursive return(AllItems.FirstOrDefault(o => o.Contains(key) && o[key] == value)); }
private Task <bool> OnSaveAsync(EditFooTree item) { if (item.Id == 0) { item.Id = AllItems.Max(i => i.Id) + 1; AllItems.Add(item); } else { var oldItem = AllItems.FirstOrDefault(i => i.Id == item.Id); if (oldItem != null) { oldItem.ParentId = item.ParentId; oldItem.Name = item.Name; oldItem.DateTime = item.DateTime; oldItem.Address = item.Address; oldItem.Count = item.Count; } } return(Task.FromResult(true)); }
public Item FindItem(Func <Item, bool> predicate, bool recursive) { Item match = AllItems.FirstOrDefault(i => predicate(i)); if (match == null && recursive) { foreach (var item in AllItems) { if (item == null) { continue; } if (item.OwnInventory != null) { match = item.OwnInventory.FindItem(predicate, recursive: true); if (match != null) { return(match); } } } } return(match); }
public Item GetItemById(int itemId) { return(AllItems.FirstOrDefault(i => i.ItemId == itemId)); }
public virtual TE Get(params object [] ids) { var r = AllItems.FirstOrDefault(i => ids.Contains(i.Id)); return(r); }
public Ingredient GetById(int ingredientId) { return(AllItems.FirstOrDefault(i => i.Id == ingredientId)); }
public Formulation GetById(int formulationId) { return(AllItems.FirstOrDefault(f => f.Id == formulationId)); }
public Person GetByLogin(string login) { return(AllItems.FirstOrDefault(p => p.Login.Equals(login))); }
public Person GetByLogin(string login, string password) { var user = GetByLogin(login); return(AllItems.FirstOrDefault(p => p.Login.Equals(login) && p.Password.Equals(password))); }
public virtual TE GetByName(string name) { var r = AllItems.FirstOrDefault(i => i.Name.Equals(name, System.StringComparison.InvariantCultureIgnoreCase)); return(r); }
public virtual TE Get(TI id) { var r = AllItems.FirstOrDefault(i => i.Id.ToString() == (id.ToString())); return(r); }
public override AdminCustom GetByName(string name) { var r = AllItems.FirstOrDefault(i => i.Name.Equals(name)); return(r); }
public OapChecklistSubGroup GetBySubGroupName(int groupId, string name) { return(AllItems.FirstOrDefault(sg => sg.OapChecklistGroupId == groupId && sg.Name.Equals(name))); }
protected virtual void OnModelDeletedToRepository(object sender, ModelDeletedEventArgs e) { AllItems.Remove(AllItems.FirstOrDefault <ItemsViewModel>(item => item.IsSelected)); }
public override Client ReadEntry(int id) { return(AllItems.FirstOrDefault(c => c.Id == id)); }
public ItemMaster GetItemById(int itemId) { return(AllItems.FirstOrDefault(p => p.ItemId == itemId)); }