private void CategoryDelete() { string selete = SelectCategory; FileInfo fileInfo = new FileInfo(CATEGORY_FILE_PATH + selete + CATEGORY_FILE_NAME); if (fileInfo.Exists) { fileInfo.Delete(); Categories.Remove(Categories.Where(x => x.Name.Equals(selete)).Single()); CategoryNames.Remove(CategoryNames.Where(x => x.Equals(selete)).Single()); } }
public async System.Threading.Tasks.Task RemoveCat(Category cat) { var catIdJson = JsonConvert.SerializeObject(cat.Id); HttpClient httpClient = new HttpClient(); var url = $"http://localhost:5001/api/Category/{cat.Id}"; var res = await httpClient.DeleteAsync(new Uri(url)); if (res.IsSuccessStatusCode) { var deletedCat = Categories.SingleOrDefault((t) => t.Id == cat.Id); if (deletedCat != null) { Categories.Remove(deletedCat); CategoryNames.Remove(deletedCat.Name); Travellist.Categories.Remove(deletedCat); } } }