public static async Task DeleteProductFromBoodschappenLijstje(Supermarkt supermarkt, Product product) { IList <BoodschappenLijstje> Boodschappenlijstjes = await GetBoodschappenLijstjes(); BoodschappenLijstje BoodschappenLijstje = null; foreach (BoodschappenLijstje b in Boodschappenlijstjes) { if (b.supermarkt.Name == supermarkt.Name) { BoodschappenLijstje = b; break; } } foreach (BoodschappenlijstjeItem bi in BoodschappenLijstje.Producten) { if (bi.SupermarktItem.Name == product.Name) { BoodschappenLijstje.Producten.Remove(bi); break; } } if (BoodschappenLijstje.Producten.Count == 0) { Boodschappenlijstjes.Remove(BoodschappenLijstje); } BoodschappenLijstje.Notify(); try { StorageFile file = await localFolder.CreateFileAsync(FileName, CreationCollisionOption.ReplaceExisting); if (file != null) { string JsonString = JsonConvert.SerializeObject(await GetBoodschappenLijstjes()); await FileIO.WriteTextAsync(file, JsonString); } } catch (Exception) { //Could not save? OHOH } }
public static async Task <ProductPagina> GetDiscountsFromSupermarket(Supermarkt supermarkt, bool BackgroundTask) { string Cache = null; DiscountCache.TryGetValue(supermarkt.ID, out Cache); if (!string.IsNullOrWhiteSpace(Cache)) { return(JsonConvert.DeserializeObject <ProductPagina>(Cache)); } string SupermarktData = await HTTPGetUtil.GetDataAsStringFromURL(Host + "GetProductPageBySupermarketID/" + supermarkt.ID); if (!string.IsNullOrWhiteSpace(SupermarktData)) { DiscountCache.Add(supermarkt.ID, SupermarktData); } ProductPagina p = JsonConvert.DeserializeObject <ProductPagina>(SupermarktData); await NotifcationDataHandler.Update(supermarkt.Name, p.DiscountValid, BackgroundTask); return(p); }
public static async Task <IList <Supermarkt> > GetSelectedSuperMarkets() { return(await Supermarkt.GetSelectedSupermarketsFromStorage()); }
public SupermarketSearchResult(Supermarkt supermarkt, IList <Product> producten) { this.supermarkt = supermarkt; this.producten = producten; }
public static async Task AddProductToBoodschappenLijstje(Supermarkt supermarkt, int Count) { if (supermarkt.ProductPagina.SelectedItem == null) { return; } IList <BoodschappenLijstje> Boodschappenlijstjes = await GetBoodschappenLijstjes(); BoodschappenLijstje BoodschappenLijstje = null; foreach (BoodschappenLijstje b in Boodschappenlijstjes) { if (b.supermarkt.Name == supermarkt.Name) { BoodschappenLijstje = b; break; } } if (BoodschappenLijstje == null) { BoodschappenLijstje = new BoodschappenLijstje(supermarkt); Boodschappenlijstjes.Add(BoodschappenLijstje); } foreach (BoodschappenlijstjeItem bi in BoodschappenLijstje.Producten) { if (bi.SupermarktItem.Name == supermarkt.ProductPagina.SelectedItem.Name) { BoodschappenLijstje.Producten.Remove(bi); break; } } if (Count > 0) { BoodschappenLijstje.Producten.Add(new BoodschappenlijstjeItem(Count, supermarkt.ProductPagina.SelectedItem)); } else { if (BoodschappenLijstje.Producten.Count == 0) { Boodschappenlijstjes.Remove(BoodschappenLijstje); } } try { StorageFile file = await localFolder.CreateFileAsync(FileName, CreationCollisionOption.ReplaceExisting); if (file != null) { string JsonString = JsonConvert.SerializeObject(await GetBoodschappenLijstjes()); await FileIO.WriteTextAsync(file, JsonString); } } catch (Exception) { //Could not save? OHOH } return; }
public BoodschappenLijstje(Supermarkt supermarkt) { this.supermarkt = supermarkt; this.Producten = new ObservableCollection <BoodschappenlijstjeItem>(); }
public ProductPagina(int ID, string DiscountValid, IList <Product> Producten, Supermarkt supermarkt) { this.ID = ID; this.supermarkt = supermarkt; this.DiscountValid = DiscountValid; this.Producten = Producten.OrderBy(p => p.Name).ToList(); }