public async Task <IEnumerable <Product> > GetSpecialsByProductName(string productName) { var searchService = new ProductSearchService(); var products = await searchService.Search(productName); return(products.Where(x => x.IsOnSpecial)); }
public void GetMusicContractsScenario(string filterText, IEnumerable <MusicContract> musicContracts, IEnumerable <DistributionPartnerContract> distributionPartnerContracts, string expectedSongs) { var musicContractRepo = new Mock <IRepository <MusicContract> >(); var distPartnerContractRepo = new Mock <IRepository <DistributionPartnerContract> >(); var searchService = new ProductSearchService(distPartnerContractRepo.Object, musicContractRepo.Object); var actualSongs = ""; ProductFilter filter = null; $"Given a filter '{filterText} is provided".x(() => { musicContractRepo.Setup(r => r.GetAll()).Returns(musicContracts); distPartnerContractRepo.Setup(r => r.GetAll()).Returns(distributionPartnerContracts); filter = ProductFilterBuilder.From(filterText).Build(); }); "When GetMusicContracts is called" .x(() => { var results = searchService.GetMusicContracts(filter); actualSongs = string.Join(',', results.Select(x => x.Title)); }); "Then all music contracts should be returned" .x(() => { actualSongs.Should().Be(expectedSongs); }); }
void UpdateProducts() { var productSearchService = new ProductSearchService(); Cursor.Current = Cursors.WaitCursor; try { // get all products for category InitializeGridProductType1(dataGridViewProducts1); dataGridViewProducts1.AutoGenerateColumns = false; dataGridViewProducts1.DataSource = productSearchService.ProductSearchByCategory( _productCategoryId, _onParent ); dataGridViewProducts1.AutoResizeColumns(); dataGridViewProducts1.Refresh(); } catch (Exception ex) { Error(ex); } finally { productSearchService.Close(); } Cursor.Current = Cursors.Default; }
private async Task <DialogTurnResult> AddedItemToCartStep(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var shoppingMessage = MessageFactory.Text(""); var orderDetail = await OrderObjectStatePropertyAccessor.GetAsync(stepContext.Context, cancellationToken : cancellationToken); if (orderDetail.QuantityString.Contains("more")) { shoppingMessage = MessageFactory.Text("ඔබට අවශයය ප්රමාණය ඇතුලත් කරන්න....."); return(await stepContext.PromptAsync("QtyPrompt", new PromptOptions { Prompt = shoppingMessage }, cancellationToken : cancellationToken)); } else { var products = new ProductSearchService().GetAllProducts(); var product = products.FirstOrDefault(a => a.Id == orderDetail.ProductId); shoppingMessage = MessageFactory.Text($" {product.Name_SI} {orderDetail.Quantity} ක් ඇතුලත් කරන ල්දී.ඔබට වෙනත් යමක් අවශ්යයිද?"); await stepContext.Context.SendActivityAsync(shoppingMessage, cancellationToken); await OrderObjectStatePropertyAccessor.DeleteAsync(stepContext.Context, cancellationToken); return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken)); } }
public async Task <IEnumerable <Product> > GetSpecialsByCategory(string category = null) { var searchService = new ProductSearchService(); var products = await searchService.SearchSpecials(category); return(products.Where(x => x.IsOnSpecial)); }
public SearchServiceResponse SearchProducts() { ProductSearchService products = new ProductSearchService(AppRuntime.MarketWebClient, "api/v1/products"); var result = products.GetSearchResult().Result; return(result); }
public SearchResultViewModelBuilder(RequestModelAccessor requestModelAccessor, ProductSearchService productSearchService, ProductItemViewModelBuilder productItemBuilder, PageSearchService pageSearchService, CategorySearchService categorySearchService) { _requestModelAccessor = requestModelAccessor; _productSearchService = productSearchService; _productItemBuilder = productItemBuilder; _pageSearchService = pageSearchService; _categorySearchService = categorySearchService; }
public ActionResult ProductSearchIndex(System.Guid productCategoryId, System.Boolean onParent) { List <ProductSearchByCategoryContract> productSearch = new ProductSearchService().ProductSearchByCategory(productCategoryId, onParent); return(View( "~/Views/Templates/Product/ProductSearch/ProductSearchIndex.cshtml", productSearch )); }
public BrandListViewModelBuilder( RequestModelAccessor requestModelAccessor, PageService pageService, UrlService urlService, ProductSearchService productSearchService) { _pageService = pageService; _urlService = urlService; _requestModelAccessor = requestModelAccessor; _productSearchService = productSearchService; }
public FilterAggregatorImpl( CategoryService categoryService, CurrencyService currencyService, UrlService urlService, ProductSearchService productSearchService, RequestModelAccessor requestModelAccessor) : base(categoryService, currencyService, urlService) { _productSearchService = productSearchService; _requestModelAccessor = requestModelAccessor; }
public ProductSearchServiceDecorator( ProductSearchService parent, SearchClientService searchClientService, RequestModelAccessor requestModelAccessor, SearchResultTransformationService searchResultTransformationService, SearchQueryBuilder searchQueryBuilder) { _parent = parent; _searchClientService = searchClientService; _requestModelAccessor = requestModelAccessor; _searchResultTransformationService = searchResultTransformationService; _searchQueryBuilder = searchQueryBuilder; }
public ProductBlockViewModelBuilder(ProductModelBuilder productModelBuilder, ProductItemViewModelBuilder productItemViewModelBuilder, RequestModelAccessor requestModelAccessor, ProductSearchService productSearchService, BaseProductService baseProductService, VariantService variantService) { _productModelBuilder = productModelBuilder; _productItemViewModelBuilder = productItemViewModelBuilder; _requestModelAccessor = requestModelAccessor; _productSearchService = productSearchService; _baseProductService = baseProductService; _variantService = variantService; }
public CategoryPageViewModelBuilder(CategoryService categoryService, ProductItemViewModelBuilder productItemBuilder, LandingPageViewModelBuilder landingPageViewModelBuilder, ProductSearchService productSearchService, RequestModelAccessor requestModelAccessor, PageByFieldTemplateCache <LandingPageByFieldTemplateCache> landingPageByFieldTemplateCache) { _categoryService = categoryService; _productItemBuilder = productItemBuilder; _landingPageViewModelBuilder = landingPageViewModelBuilder; _productSearchService = productSearchService; _requestModelAccessor = requestModelAccessor; _landingPageByFieldTemplateCache = landingPageByFieldTemplateCache; }
// GET: ProductSearch public ActionResult Index() { ProductSearchService productSearchService = new ProductSearchService(); ProductSearchModel p = new ProductSearchModel { subcategoryNames = productSearchService.getSubcategoryNames(), subcategoryIDs = productSearchService.getSubcategoryIDs(), departmentNames = productSearchService.getDepartmentNames(), subCategoryDepartmentDict = productSearchService.getSubcategoryDepartmentDict() }; Session.Add("productObject", p); //ViewData["productNames"] = p.productNames; return(View()); }
private async Task ShowProductListAndAskForMore(DialogContext dc, String SearchQuery, CancellationToken cancellationToken) { var productList = new ProductSearchService().SearchProductByName(SearchQuery); if (productList != null && productList.Count > 0) { await SendProductList(dc.Context, productList, cancellationToken); } else { await dc.Context.SendActivityAsync("කණගාටුයි මට ඔබ වෙනුවෙන් කිසිදු නිෂ්පාදනයක් සොයාගත නොහැකි විය.", cancellationToken : cancellationToken); } await Helper.SendConfirmationPrompt("ඔබට වෙනත් යමක් අවශයයිද ??", dc.Context, cancellationToken); await LastAskedAccessor.SetAsync(dc.Context, "anythingelse", cancellationToken : cancellationToken); }
private async Task ShowProductListAndAskForMore(DialogContext dc, String SearchQuery, CancellationToken cancellationToken) { var productList = new ProductSearchService().SearchProductByName(SearchQuery); if (productList != null && productList.Count > 0) { await SendProductList(dc.Context, productList, cancellationToken); } else { await dc.Context.SendActivityAsync("Sorry I couldn't find any products for you.", cancellationToken : cancellationToken); } await Helper.SendConfirmationPrompt("ඔබට වෙනත් යමක් අවශයයිද ??", dc.Context, cancellationToken); await LastAskedAccessor.SetAsync(dc.Context, "anythingelse", cancellationToken : cancellationToken); }
public ProductSearchServiceDecorator( ProductSearchService parent, SearchClientService searchClientService, RequestModelAccessor requestModelAccessor, SearchResultTransformationService searchResultTransformationService, SearchQueryBuilder searchQueryBuilder, TargetGroupEngine targetGroupEngine, FieldDefinitionService fieldDefinitionService) : base(targetGroupEngine) { _parent = parent; _searchClientService = searchClientService; _requestModelAccessor = requestModelAccessor; _searchResultTransformationService = searchResultTransformationService; _searchQueryBuilder = searchQueryBuilder; _fieldDefinitionService = fieldDefinitionService; }
private async Task <DialogTurnResult> GetQuantityStep(WaterfallStepContext stepContext, CancellationToken cancellationToken) { int qty = 0; try { //qty = int.Parse(new TokenizationLibrary().GetNumericalValues((string)stepContext.Result)); qty = (int)stepContext.Result; } catch (System.InvalidCastException) { await stepContext.CancelAllDialogsAsync(cancellationToken); return(await stepContext.BeginDialogAsync(nameof(MainDialog), "no_intro_msg", cancellationToken : cancellationToken)); } catch (System.NullReferenceException) { await stepContext.CancelAllDialogsAsync(cancellationToken); return(await stepContext.BeginDialogAsync(nameof(MainDialog), "no_intro_msg", cancellationToken : cancellationToken)); } var orderDetail = await OrderObjectStatePropertyAccessor.GetAsync(stepContext.Context, cancellationToken : cancellationToken); if (qty > 0) { var products = new ProductSearchService().GetAllProducts(); var product = products.FirstOrDefault(a => a.Id == orderDetail.ProductId); orderDetail.Quantity = qty; orderDetail.ProductName = product.Name_SI; await OrderObjectStatePropertyAccessor.SetAsync(stepContext.Context, orderDetail, cancellationToken : cancellationToken); var shoppingMessage = MessageFactory.Text($"{product.Name_SI} {qty} ක් ඇතුලත් කරන්නද ??"); return(await stepContext.PromptAsync("AddCartConfirm", new PromptOptions { Prompt = shoppingMessage }, cancellationToken : cancellationToken)); } else { await stepContext.Context.SendActivityAsync($"හරි..එසේනම් {orderDetail.ProductName} ඇතුලත් කරන්නෙ නෑ.ඔබට වෙනත් යමක් අවශ්යයිද?"); await OrderObjectStatePropertyAccessor.DeleteAsync(stepContext.Context, cancellationToken); return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken)); } }
public void GetMusicContractsNoFilterScenario() { var musicContractRepo = new Mock <IRepository <MusicContract> >(); var distPartnerContractRepo = new Mock <IRepository <DistributionPartnerContract> >(); var searchService = new ProductSearchService(distPartnerContractRepo.Object, musicContractRepo.Object); var actualCount = 0; var expectedCount = StaticData.MusicContracts.Count(); "Given no filter is provided".x(() => { musicContractRepo.Setup(r => r.GetAll()).Returns(StaticData.MusicContracts); }); "When GetMusicContracts is called" .x(() => { actualCount = searchService.GetMusicContracts(null).Count(); }); "Then all music contracts should be returned" .x(() => { actualCount.Should().Be(expectedCount); }); }
public async Task <IEnumerable <Product> > Get(string productName) { var searchService = new ProductSearchService(); return(await searchService.Search(productName)); }
public ProductListViewModelBuilder(RequestModelAccessor requestModelAccessor, ProductSearchService productSearchService, ProductItemViewModelBuilder productItemBuilder) { _requestModelAccessor = requestModelAccessor; _productSearchService = productSearchService; _productItemBuilder = productItemBuilder; }
public BrandViewModelBuilder(RequestModelAccessor requestModelAccessor, ProductItemViewModelBuilder productItemViewModelBuilder, ProductSearchService productSearchService) { _requestModelAccessor = requestModelAccessor; _productItemViewModelBuilder = productItemViewModelBuilder; _productSearchService = productSearchService; }
public ProductSearcher(ProductSearchService productSearchService, RequestModelAccessor requestModelAccessor) { _productSearchService = productSearchService; _requestModelAccessor = requestModelAccessor; }