예제 #1
0
        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;
        }
예제 #2
0
        private void PlayCmd(long mediaItemId)
        {
            var mediaItem = AllItems.FirstOrDefault(item => item.Id == mediaItemId);

            if (mediaItem != null)
            {
                Process.Start(mediaItem.Path);
            }
        }
예제 #3
0
        public ITestObject FindFirst(Func <ITestObject, bool> func, bool recursive = true)
        {
            if (!recursive)
            {
                return(_testObjects.Values.FirstOrDefault(func));
            }

            //recursive
            return(AllItems.FirstOrDefault(func));
        }
예제 #4
0
        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);
            });
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
        /// <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));
        }
예제 #7
0
 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));
 }
예제 #8
0
        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);
        }
예제 #9
0
 public Item GetItemById(int itemId)
 {
     return(AllItems.FirstOrDefault(i => i.ItemId == itemId));
 }
예제 #10
0
        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));
 }
예제 #12
0
 public Formulation GetById(int formulationId)
 {
     return(AllItems.FirstOrDefault(f => f.Id == formulationId));
 }
예제 #13
0
 public Person GetByLogin(string login)
 {
     return(AllItems.FirstOrDefault(p => p.Login.Equals(login)));
 }
예제 #14
0
        public Person GetByLogin(string login, string password)
        {
            var user = GetByLogin(login);

            return(AllItems.FirstOrDefault(p => p.Login.Equals(login) && p.Password.Equals(password)));
        }
예제 #15
0
        public virtual TE GetByName(string name)
        {
            var r = AllItems.FirstOrDefault(i => i.Name.Equals(name, System.StringComparison.InvariantCultureIgnoreCase));

            return(r);
        }
예제 #16
0
        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));
 }
예제 #20
0
 public override Client ReadEntry(int id)
 {
     return(AllItems.FirstOrDefault(c => c.Id == id));
 }
예제 #21
0
 public ItemMaster GetItemById(int itemId)
 {
     return(AllItems.FirstOrDefault(p => p.ItemId == itemId));
 }