public Option <ShoppingListEntry> AsShoppingListEntry()
        {
            SettingsService settings = _settingsService.Value;
            IEnumerable <GroceryItemType> itemTypes = settings.GroceryTypes.AsObservableList().Items;

            GroceryItemType itemType = itemTypes.FirstOrDefault(x => x.ItemTypeId.ToString() == this.DataId);

            if (itemType == null)
            {
                itemType = itemTypes.FirstOrDefault(x => x.Name == this.Content);
            }

            if (itemType == null)
            {
                return(Option.None <ShoppingListEntry>());
            }

            uint itemCount;
            bool parseItemCountSuccess = UInt32.TryParse(this.Content.Substring(this.Content.LastIndexOf('x') + 1), out itemCount);

            return(new ShoppingListEntry
            {
                ItemType = itemType,
                Count = parseItemCountSuccess ? itemCount : 1
            }.Some());
        }
Exemple #2
0
 public InventoryEntry(GroceryItemType item, IEnumerable <DateTime> expiryTimes)
 {
     ItemType    = item;
     ExpiryDates = new ObservableCollectionExtended <DateTime>(expiryTimes.OrderBy(x => x));
 }
Exemple #3
0
 public InventoryEntry(GroceryItemType item, DateTime singleItemExpiry)
 {
     ItemType = item;
     ExpiryDates.Add(singleItemExpiry); //todo make this do an AddSorted()
 }