public ActionResult Search(ProductSearchModel model) { try { int totalRow = 0; var lstProduct = _productBo.GetList(model.KeyWord, out totalRow, model.PageIndex, model.PageSize).ToList(); if (lstProduct.Any()) { var lstModel = lstProduct.Select(x => new ProductViewModel(x)); var pager = new Pager { CurrentPage = model.PageIndex, PageSize = model.PageSize, TotalItem = totalRow }; Msg.Obj = new { Data = lstModel, Pager = pager }; Msg.Error = false; } else { Msg.Obj = new { Data = lstProduct, Pager = new Pager() }; } } catch (Exception ex) { Msg.Obj = null; Msg.Error = true; } return(AuthorizeJson(Msg)); }
public async Task <IEnumerable <ProductListModel> > GetProducts(ProductSearchModel searchModel) { using (var con = new SqlConnection(_databaseRepository.ConnectionString)) { await con.OpenAsync(); using (var cmd = con.CreateCommand()) { cmd.CommandText = "[dbo].[GetAllProducts]"; cmd.Parameters.Add("@SearchText", SqlDbType.VarChar).Value = searchModel.Name; if (searchModel.pageList != null) { cmd.Parameters.Add("@RecordStart", SqlDbType.Int).Value = searchModel.pageList.RecordStart; cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value = searchModel.pageList.PageSize; cmd.Parameters.Add("@SortColumn", SqlDbType.VarChar).Value = searchModel.pageList.SortColumn; cmd.Parameters.Add("@SortOrder", SqlDbType.VarChar).Value = searchModel.pageList.SortOrder; } cmd.CommandType = CommandType.StoredProcedure; using (var reader = await cmd.ExecuteReaderAsync()) { var list = new List <ProductListModel>(); while (await reader.ReadAsync()) { list.Add(SqlMapper.Map <ProductListModel>(reader)); } return(list); } } } }
public void OnGet(ProductSearchModel searchModel) { var productCategories = _productCategoryApplication.GetProductCategories(); ProductCategories = new SelectList(productCategories, "Id", "Name"); Products = _productApplication.Search(searchModel); }
public CWProductHtmlReader() { var productSearchModel = new ProductSearchModel { BaseUrl = "http://www.chemistwarehouse.com.au" }; productSearchModel.AddIdentifier("Name", IdentifierType.ElementContent, ".//*[@class='product-name']//h1"); productSearchModel.AddIdentifier("OriginalPrice", IdentifierType.ElementContent, ".//div[@class='retailPrice']", null, false, 0, "Don't Pay RRP: $", string.Empty); productSearchModel.AddIdentifier("Picture", IdentifierType.Attribute, "src", ".//img[@class='product-thumbnail']"); productSearchModel.AddIdentifier("MetaDescription", IdentifierType.Attribute, "content", ".//meta[@name='description']"); productSearchModel.AddIdentifier("MetaKeywords", IdentifierType.Attribute, "content", ".//meta[@name='keywords']"); productSearchModel.AddIdentifier("Description", IdentifierType.ElementContent, ".//section[contains(@class, 'product-info-section') and contains(@class, 'description')]//div[@class='details']"); productSearchModel.AddIdentifier("GeneralInfo", IdentifierType.ElementContent, ".//section[contains(@class, 'product-info-section') and contains(@class, 'general-info')]//div[@class='details']"); productSearchModel.AddIdentifier("Miscellaneous", IdentifierType.ElementContent, ".//section[contains(@class, 'product-info-section') and contains(@class, 'miscellaneous')]//div[@class='details']"); productSearchModel.AddIdentifier("DrugInteractions", IdentifierType.ElementContent, ".//section[contains(@class, 'product-info-section') and contains(@class, 'druginteractions')]//div[@class='details']"); productSearchModel.AddIdentifier("Warnings", IdentifierType.ElementContent, ".//section[contains(@class, 'product-info-section') and contains(@class, 'warnings')]//div[@class='details']"); productSearchModel.AddIdentifier("CommonUses", IdentifierType.ElementContent, ".//section[contains(@class, 'product-info-section') and contains(@class, 'commonuses')]//div[@class='details']"); productSearchModel.AddIdentifier("Ingredients", IdentifierType.ElementContent, ".//section[contains(@class, 'product-info-section') and contains(@class, 'ingredients')]//div[@class='details']"); productSearchModel.AddIdentifier("Directions", IdentifierType.ElementContent, ".//section[contains(@class, 'product-info-section') and contains(@class, 'directions')]//div[@class='details']"); productSearchModel.AddIdentifier("Indications", IdentifierType.ElementContent, ".//section[contains(@class, 'product-info-section') and contains(@class, 'indications')]//div[@class='details']"); ProductSearchModel = productSearchModel; }
public ActionResult Index() { ProductSearchModel _ProductViewModel = new ProductSearchModel { Sizes = processManager.GetSizes().Select(x => new SelectListItem { Value = x.SizeId.ToString(), Text = x.SizeName }), Brands = processManager.GetBrands().Select(x => new SelectListItem { Value = x.BrandId.ToString(), Text = x.BrandName }), Colours = processManager.GetColours().Select(x => new SelectListItem { Value = x.ColourId.ToString(), Text = x.ColourName }), Customers = processManager.GetCustomers().Select(x => new SelectListItem { Value = x.CustomerId.ToString(), Text = x.CustomerName }), Products = processManager.GetProducts() }; return(View(_ProductViewModel)); }
public IQeryable <Product> GetProducts(ProductSearchModel searchModel) { var result = Context.Products.AsQeryable(); if (searchModel != null) { if (searchModel.Id.HasValue) { result = result.Where(x => x.Id == searchModel.Id); } if (!string.IsNullOrEmplty(searchModel.Name)) { result = result.Where(x => x.Name.Contains(searchModel.Name)); } if (searchModel.PriceFrom.HasValue) { result = result.Where(x => x.Price >= searchModel.PriceFrom); } if (searchModel.PriceTo.HasValue) { result = result.Where(x => x.Price <= searchModel.PriceTo); } } return(result); }
public PartialViewResult _GetProducts(ProductSearchModel search) { List <UserProducts> list = new List <UserProducts>(); list = _proM.GetProducts(search); return(PartialView(list)); }
public IQueryable <tblPatient> GetSearchResults(ProductSearchModel searchModel) { var result = Context.tblPatients.AsQueryable(); if (searchModel != null) { if (searchModel.Patient_ID.HasValue) { result = result.Where(x => x.Patient_id == searchModel.Patient_ID); } if (!string.IsNullOrEmpty(searchModel.Patient_Name)) { result = result.Where(x => x.Patient_Name.Contains(searchModel.Patient_Name)); } if (!string.IsNullOrEmpty(searchModel.Patient_Address)) { result = result.Where(x => x.Patient_address.Contains(searchModel.Patient_Address)); } if (!string.IsNullOrEmpty(searchModel.Contact_Number)) { result = result.Where(x => x.Contact_no.Contains(searchModel.Contact_Number)); } } return(result); }
public List <ProductViewModel> Search(ProductSearchModel searchModel) { var query = _db.Products.Include(p => p.Category).Select(p => new ProductViewModel() { Id = p.Id, Category = p.Category.Name, CategoryId = p.CategoryId, Picture = p.Picture, Code = p.Code, CreationDate = p.CreationDate.ToPersianDate(), Name = p.Name }); if (searchModel.CategoryId != 0) { query = query.Where(p => p.CategoryId == searchModel.CategoryId); } if (!string.IsNullOrWhiteSpace(searchModel.Name)) { query = query.Where(p => p.Name.Contains(searchModel.Name)); } if (!string.IsNullOrWhiteSpace(searchModel.Code)) { query = query.Where(p => p.Name.Contains(searchModel.Code)); } return(query.OrderByDescending(p => p.CategoryId).ThenBy(p => p.Id).AsNoTracking().ToList()); }
public async Task <ActionResult> GetProductList(string name = null) { var draw = Request.Form.GetValues("draw").FirstOrDefault(); var start = Request.Form.GetValues("start").FirstOrDefault(); var sortColumn = ""; var sortColumnDir = "ASC"; var pageList = new PageList() { PageSize = 5, SortColumn = sortColumn, SortOrder = sortColumnDir.ToUpper(), }; pageList.RecordStart = start != null?Convert.ToInt32(start) : 0; ProductSearchModel searchModel = new ProductSearchModel(); searchModel.pageList = pageList; searchModel.Name = name; var result = await productService.GetProducts(searchModel); long recordsTotal = 0; if (result.Any()) { recordsTotal = result.FirstOrDefault().TotalCount; } return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = result }, JsonRequestBehavior.AllowGet)); }
public IActionResult Product(int sellerId, string searchString, int?categoryId, decimal?price, short?priceIndication, ProductStatus?status, bool?active, ProductTypeStatus?productTypeStatus, short?page = 1) { ProductSearchModel searchModel = new ProductSearchModel { SellerId = sellerId, SearchString = searchString, CategoryId = categoryId, Price = price, PriceIndication = priceIndication, Status = status, Active = active, ProductTypeStatus = productTypeStatus }; ViewData[GlobalViewBagKeys.ECommerceService] = eCommerce; return(View(new ProductsListViewModel { Products = eCommerce.GetProductsBySellerId(searchModel, (page - 1) * recordsPerPage, recordsPerPage), PagingInfo = new PagingInfo { CurrentPage = (short)page, RecordsPerPage = recordsPerPage, TotalRecords = eCommerce.CountProductsBySellerId(searchModel) }, SearchModel = searchModel })); }
public ProductSearchViewModel(UserInformation userInformation) { try { this._userInformation = userInformation; _productSearchBll = new ProductSearchBll(this._userInformation); ProdSearchModel = new ProductSearchModel(); SetdropDownItems(); GetAllCombo(); this.searchCommand = new DelegateCommand(this.Search); this.selectionChangedManufacturedCommand = new DelegateCommand(this.FilterCostCentre); this.selectionChangedFamilyCommand = new DelegateCommand(this.FilterAll); this.closeCommand = new DelegateCommand(this.CloseSubmit); this.showProductInformationCommand = new DelegateCommand(this.ShowProductInformation); this.printCommand = new DelegateCommand(this.PrintProductSearch); this.previewMouseLeftButtonDownCommand = new DelegateCommand(this.ValidateApplicationCombo); ProdSearchModel.TotalRecords = "Part Details"; ProdSearchModel.HeatTreatment = "678WERER@#$%^&$#"; ProductResult = _productSearchBll.GetProductSearchDetails(ProdSearchModel); ProductResult.AddNew(); ProdSearchModel.HeatTreatment = ""; NotifyPropertyChanged("ProductResult"); } catch (Exception ex) { } }
public List <ProductViewModel> Search(ProductSearchModel searchModel) { var query = _context.Products .Include(x => x.Category) .Select(x => new ProductViewModel { Id = x.Id, Name = x.Name, Category = x.Category.Name, CategoryId = x.CategoryId, Code = x.Code, Picture = x.Picture, CreationDate = x.CreationDate.ToFarsi() }); if (!string.IsNullOrWhiteSpace(searchModel.Name)) { query = query.Where(x => x.Name.Contains(searchModel.Name)); } if (!string.IsNullOrWhiteSpace(searchModel.Code)) { query = query.Where(x => x.Code.Contains(searchModel.Code)); } if (searchModel.CategoryId != 0) { query = query.Where(x => x.CategoryId == searchModel.CategoryId); } return(query.OrderByDescending(x => x.Id).ToList()); }
private void ProductSelectedExecute(ProductSearchModel model) { SnipInsightViewModel viewModel = AppManager.TheBoss.ViewModel; var aiPanelVM = ServiceLocator.Current.GetInstance <AIPanelViewModel>(); AppManager.TheBoss.OnSaveImage(); if (string.IsNullOrEmpty(viewModel.RestoreImageUrl)) { viewModel.RestoreImageUrl = viewModel.SavedCaptureImage; } ImageLoader.LoadFromUrl(new Uri(model.ContentUrl)).ContinueWith(t => { Application.Current.Dispatcher.Invoke(() => { aiPanelVM.CapturedImage = t.Result; viewModel.SelectedImageUrl = model.ContentUrl; AppManager.TheBoss.RunAllInsights(); }); }, TaskContinuationOptions.OnlyOnRanToCompletion); ImageLoader.LoadFromUrl(new Uri(model.ContentUrl)).ContinueWith(t => { MessageBox.Show(Resources.Image_Not_Loaded); }, TaskContinuationOptions.NotOnRanToCompletion); }
public ActionResult ProductSearch(string ProductGroupName, string BrandName, string ModelName) { ProductSearchModel model = new ProductSearchModel(); model.ProductGroupName = ProductGroupName; model.BrandName = BrandName; model.ModelName = ModelName; PrepareCategoryHash categoryHash = new PrepareCategoryHash(); categoryHash.CreateHashTableAndProductTree(); Hashtable categoryTable = categoryHash.GetCategoryTable; var categories = _categoryService.GetAllCategory().Where(x => x.CategoryType == (byte)CategoryType.Category); List <ProductItemModel> productList = new List <ProductItemModel>(); foreach (var item in categories) { var tree = (ProductGroupTree)categoryTable[item.CategoryName]; var treeNode = tree.GetProductTreeNodeByProductGroupName(tree.GetRoot(), ProductGroupName); if (treeNode.ProductBase != null) { var anyProduct = treeNode.ProductBase.Products.Where(x => x.ModelName == ModelName && x.BrandName == BrandName).ToList(); if (anyProduct.Count > 0) { productList.AddRange(anyProduct); } } } model.Products = productList; return(View(model)); }
public async Task <IActionResult> Index(ProductSearchModel parameters = null) { UserContext userContext = session.GetObjectFromJson <UserContext>(UserContext.SESSION_NAME.ToString()); ProductsManager.Criteria criteria = new ProductsManager.Criteria(); if (parameters != null) { criteria.name = parameters.productName; criteria.productTypesId = parameters.productTypesId; } List <Products> productses = await productsManager.ExcuteQuery(criteria); productsManager.PrepareData(productses); ViewData["searchParameters"] = parameters; //取得產品類別的清單 List <ProductTypes> productTypeses = productTypesManager.GetEntitiesQ().ToList(); List <SelectListItem> items = productTypesManager.GetProductSelectListItem(); ViewData["productTypeses"] = items; return(View(productses)); }
public ActionResult Index(string searchString, int SizeID = -1, int BrandID = -1, int ColourID = -1, int CustomerID = -1) { ProductSearchParameters _Params = new ProductSearchParameters(); if (SizeID != -1) { _Params.SizeIds.Add(SizeID); } if (BrandID != -1) { _Params.BrandIds.Add(BrandID); } if (ColourID != -1) { _Params.ColourIds.Add(ColourID); } if (searchString.Length > 0) { _Params.SearchString = searchString; } ProductSearchModel _ProductViewModel = new ProductSearchModel { Sizes = processManager.GetSizes().Select(x => new SelectListItem { Value = x.SizeId.ToString(), Text = x.SizeName }), Brands = processManager.GetBrands().Select(x => new SelectListItem { Value = x.BrandId.ToString(), Text = x.BrandName }), Colours = processManager.GetColours().Select(x => new SelectListItem { Value = x.ColourId.ToString(), Text = x.ColourName }), Customers = processManager.GetCustomers().Select(x => new SelectListItem { Value = x.CustomerId.ToString(), Text = x.CustomerName }) }; if (CustomerID != -1) { _ProductViewModel.Products = processManager.CustomerProductSearch(CustomerID, _Params); } else { _ProductViewModel.Products = processManager.ProductSearch(_Params); } return(View(_ProductViewModel)); }
public JsonResult Get(ProductSearchModel searchModel) { using (var productService = new ProductService()) { var products = productService.GetProductList(searchModel); return(Json(products, JsonRequestBehavior.AllowGet)); } }
public SearchResult <ProductSearchInfoForCourier> SearchProduct([FromQuery] ProductSearchModel model) { var products = _productService.Search(model.SearchString, model.DateFilter, model.DeliveryTypeFilter, null, null); return(new SearchResult <ProductSearchInfoForCourier>( products.Count(), SortManager.SortProductsForCourier(products, model.ProductSortField, model.Direction, model.Count, model.Offset))); }
public IActionResult ProductSearch(ProductSearchModel searchModel) { if (searchModel.Search.IsNullEmptyOrWhiteSpace()) { return(RedirectToRoute(RouteNames.Home)); } return(ProductsListApi(searchModel)); }
public async Task <IActionResult> SearchForProduct([FromForm] ProductSearchModel model) { var products = await _productService.Search(model.Name); return(View("SearchResult", new SearchResultModel { Products = products })); }
/// <summary> /// Prepare paged product list model /// </summary> /// <param name="searchModel">Product search model</param> /// <returns>Product list model</returns> public virtual ProductListModel PrepareProductListModel(ProductSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get parameters to filter comments var overridePublished = searchModel.SearchPublishedId == 0 ? null : (bool?)(searchModel.SearchPublishedId == 1); if (_workContext.CurrentVendor != null) { searchModel.SearchVendorId = _workContext.CurrentVendor.Id; } var categoryIds = new List <int> { searchModel.SearchCategoryId }; if (searchModel.SearchIncludeSubCategories && searchModel.SearchCategoryId > 0) { var childCategoryIds = _categoryService.GetChildCategoryIds(parentCategoryId: searchModel.SearchCategoryId, showHidden: true); categoryIds.AddRange(childCategoryIds); } //get products var products = _productService.SearchProducts(showHidden: true, categoryIds: categoryIds, storeId: searchModel.SearchStoreId, vendorId: searchModel.SearchVendorId, productType: searchModel.SearchProductTypeId > 0 ? (ProductType?)searchModel.SearchProductTypeId : null, keywords: searchModel.SearchProductName, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize, overridePublished: overridePublished); //prepare list model var model = new ProductListModel { Data = products.Select(product => { //fill in model values from the entity var productModel = product.ToModel <ProductModel>(); //little performance optimization: ensure that "FullDescription" is not returned productModel.FullDescription = string.Empty; //fill in additional values (not existing in the entity) var defaultProductPicture = _pictureService.GetPicturesByProductId(product.Id, 1).FirstOrDefault(); productModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultProductPicture, 75); productModel.ProductTypeName = _localizationService.GetLocalizedEnum(product.ProductType); return(productModel); }), Total = products.TotalCount }; return(model); }
public IActionResult Index(ProductSearchModel searchModel) { var response = _productOperations.GetProductListByFilters(searchModel); ProductPageModel products = new ProductPageModel { Products = _mapper.Map <List <ProductViewModel> >(response.Data) }; return(View(products)); }
public async Task <PaginatorResponse <ProductResponseModel> > GetProducts(ProductSearchModel searchParams, bool checkSize = true) { PaginatorResponse <ProductResponseModel> result = new PaginatorResponse <ProductResponseModel>(); using (_context) { IQueryable <Product> query = _context.Products.AsQueryable(); if (searchParams.Gender > 0 && searchParams.Gender < 3) { query = query.Where(x => x.Gender == (Gender)searchParams.Gender || x.Gender == Gender.All); } if (!string.IsNullOrEmpty(searchParams.SearchText)) { query = query.Where(x => EF.Functions.Like(x.Name.ToLower(), "%" + searchParams.SearchText.ToLower() + "%")); } if (searchParams.Brand > 0) { query = query.Where(x => x.BrandId == searchParams.Brand); } if (searchParams.Category > 0) { query = query.Where(x => x.CategoryId == searchParams.Category); } result.PaginatorModel.Total = await query.CountAsync(); if (searchParams.SortBy == 2) { query = searchParams.Direction == 1 ? query.OrderBy(x => x.Name) : query.OrderByDescending(x => x.Name); } else { query = searchParams.Direction == 1 ? query.OrderBy(x => x.Price) : query.OrderByDescending(x => x.Price); } if (searchParams.PageSize > 6 && checkSize) { searchParams.PageSize = 6; } query = query.Skip(searchParams.PageIndex * searchParams.PageSize).Take(searchParams.PageSize); result.PaginatorModel.Data = await query.Select(x => new ProductResponseModel() { Notes = x.Notes, Id = x.Id, ImagePath = x.ImagePath, Name = x.Name, Price = x.Price, Quantity = x.Quantity, ResizedImagePath = x.ResizedImagePath, Subtitle = x.Category.Name + (string.IsNullOrEmpty(x.Notes) ? "" : " - " + x.Notes), Brand = x.Brand.Name }).ToListAsync(); return(result); } }
public async Task <ResponseModel <List <SearchResultProductModel> > > SearchProduct( [FromQuery] ProductSearchModel model) { var result = await _productService.SearchProduct(model); Response.StatusCode = (int)HttpStatusCode.OK; return(new ResponseBuilder <List <SearchResultProductModel> >().Success() .Data(result) .Count(result.Count) .build()); }
private bool UserHasNotSearched(ProductSearchModel productSearch) { if (productSearch.MaxPrice == null && productSearch.MinPrice == null && productSearch.ProductName == null && productSearch.Category == null) { return(true); } return(false); }
public List <UserProducts> GetProducts(ProductSearchModel search) { if (!string.IsNullOrWhiteSpace(search.SearchKey)) { search.SearchKey = "%" + search.SearchKey + "%"; } var list = _proRepo.GetByCustomQuery("select * from UserProducts where UserID = @SupplierId and (@SearchKey is null or (Name like @SearchKey or Tags like @SearchKey or Keywords like @SearchKey))", search); return(list); }
public async Task <IActionResult> CrawledDataListProductAsync(string keySearch, int commentStar) { var list = new List <Rating>(); if (!string.IsNullOrEmpty(keySearch)) { var searchModel = new ProductSearchModel(keySearch, 0); var listProduct = await _productFactory.PrepareListProductAsync(searchModel); } return(ShowCrawledData(list)); }
public IHttpActionResult GetProducts(ProductSearchModel model) { try { return(Ok(GetDataList(model))); } catch (Exception ex) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message))); } }
private void NavigateToUrlExecute(ProductSearchModel model) { try { Process.Start(model.HostPage); } catch (Win32Exception CaughtException) { MessageBox.Show(Resources.No_Browser); Console.WriteLine(CaughtException.Message); } }