public void Add(InternetShopFilter filter) { FilesProvider.OpenWriter("InternetShop"); InternetShop newCollection = new InternetShop(); if (filter.Id.HasValue) { newCollection.Id = (int)filter.Id; } if (!string.IsNullOrEmpty(filter.Name)) { newCollection.Name = filter.Name; } if (!string.IsNullOrEmpty(filter.Category)) { newCollection.Category = filter.Category; } if (!string.IsNullOrEmpty(filter.Price)) { newCollection.Price = filter.Price; } FilesProvider.WriteMusicCollection(newCollection); FilesProvider.CloseWriter(); }
public void Delete(InternetShopFilter filter) { List <InternetShop> currentCollections = Get(new InternetShopFilter()); // gets ALL the Collections, because the filter is empty here FilesProvider.OpenWriter("InternetShop", false); foreach (InternetShop Collection in currentCollections) { if (Collection.Id != filter.Id) { FilesProvider.WriteMusicCollection(Collection); } } FilesProvider.CloseWriter(); }