//Add ny item til liste public void AddNew() { //Test på værdier if (!String.IsNullOrWhiteSpace(NewGrocItem.grocItem) && !String.IsNullOrWhiteSpace(NewGrocItem.itemQnty)) { if (NewGrocItem.itemQnty.All(Char.IsDigit)) { //Instancer et container objekt OutputToUser = String.Empty; GrocItem tempGrocItem = new GrocItem(); tempGrocItem.grocItem = NewGrocItem.grocItem; tempGrocItem.itemQnty = NewGrocItem.itemQnty; //Add til list GrocList.Add(tempGrocItem); } else { OutputToUser = "******"; } } else { OutputToUser = "******"; } }
//Til at clear list public void Clear() { if (GrocList.Count > 0) { GrocList.Clear(); OutputToUser = String.Empty; } else { OutputToUser = "******"; } }
//Metode til at gemme i fil - Json format! private async void SaveList_Async() { if (GrocList.Count > 0) { OutputToUser = String.Empty; StorageFile localFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(localFile, GrocList.GetJson()); } else { OutputToUser = "******"; } }
//Remove item fra liste public void Remove() { if (GrocList.Count == 0) { OutputToUser = "******"; } else { if (SelectedGrocItem != null) { OutputToUser = String.Empty; GrocList.Remove(SelectedGrocItem); } else { OutputToUser = "******"; } } }