private Song GetSong() { HolidayManager holidayManager = new HolidayManager(); List <string> toSearch; RandomItemsProductPicker randomItemsProductPicker = new RandomItemsProductPicker(); List <Song> listOfSongs = new List <Song>(); if (holidayManager.IsHoliday(DateTime.Now, out toSearch)) { // search items based on the keywords if it's a holiday var listOfSearchedSongs = randomItemsProductPicker.PickItems( ReadersFactory.GetProductsReader(), ReadersFactory.GetStocksReader(), Filters.GetFilterByKeyWords(toSearch, typeof(Song)), 1); listOfSongs = listOfSearchedSongs.ConvertAll(x => (Song)x); return(listOfSongs[0]); } else { var listOfRandomBooks = randomItemsProductPicker.PickItems( ReadersFactory.GetProductsReader(), ReadersFactory.GetStocksReader(), Filters.GetFilterByType(typeof(Song)), 1); listOfSongs = listOfRandomBooks.ConvertAll(x => (Song)x); return(listOfSongs[0]); } }
private List <Product> GetProducts(List <string> userSearchText) { var filter = Filters.GetFilterByKeyWords(userSearchText, typeof(Product), false); RandomItemsProductPicker randomProductPicker = new RandomItemsProductPicker(); List <Product> pickedProducts = randomProductPicker.PickItems(ReadersFactory.GetProductsReader(), ReadersFactory.GetStocksReader(), filter, Constants.UNLIMITED); return(pickedProducts); }