public async Task <ProductPaggingDTO> ElasticProductSearch(int page, int pageSize, string search = "") { var output = new ProductPaggingDTO(); //try //{ // var outSearchElastic = await _repoWrapper.Elastic.SearchProducts(page , pageSize , search); // output.PageSize = pageSize; // output.CurrentPage = page; // output.TotalRecord = (int)outSearchElastic.TotalRecord; // output.TotalPage = (output.TotalRecord - 1) / pageSize + 1; // output.Data = _mapper.Map<IEnumerable<ProductSearchResultDTO>>(outSearchElastic.Products); //} //catch (Exception ex) //{ var parameters = new ProductFilter { Keyword = search, StatusTypeId = 4 }; var result = await _repoWrapper.Product.GetListProductPagging(parameters); var firstItem = result.FirstOrDefault(); int totalRow = (int)(firstItem?.TotalRows ?? 0); output.PageSize = pageSize; output.CurrentPage = page; output.TotalRecord = totalRow; output.TotalPage = (totalRow - 1) / pageSize + 1; output.Data = _mapper.Map <IEnumerable <ProductSearchResultDTO> >(result); return(output); //} return(output); }
public async Task <ProductPaggingDTO> GetLstProductForSellShopMan([FromQuery] ProductShopManFilter model) { var output = new ProductPaggingDTO(); if (model.ProductTypeId == 5) { var resultAcc = await _repoWrapper.Product.GetListAccesories(_mapper.Map <ProductFilter>(model)); var firstItemAcc = resultAcc.FirstOrDefault(); int totalRowAcc = (int)(firstItemAcc?.TotalRows ?? 0); output.PageSize = model.PageSize; output.CurrentPage = model.Page; output.TotalRecord = totalRowAcc; output.TotalPage = (totalRowAcc - 1) / model.PageSize + 1; output.Data = _mapper.Map <IEnumerable <ProductSearchResultDTO> >(resultAcc); return(output); } var result = await _repoWrapper.Product.GetLstProductForSellShopMan(model); var firstItem = result.FirstOrDefault(); int totalRow = (int)(firstItem?.TotalRows ?? 0); output.PageSize = model.PageSize; output.CurrentPage = model.Page; output.TotalRecord = totalRow; output.TotalPage = (totalRow - 1) / model.PageSize + 1; output.Data = _mapper.Map <IEnumerable <ProductSearchResultDTO> >(result); return(output); }
public async Task <ProductPaggingDTO> GetListProduct([FromQuery] ProductFilter parameters) { if (parameters.ProductTypeId == 5 || parameters.ProductTypeId == 6) { var result = await _repoWrapper.Product.GetListAccesories(parameters); var firstItem = result.FirstOrDefault(); int totalRow = (int)(firstItem?.TotalRows ?? 0); var output = new ProductPaggingDTO(); output.PageSize = parameters.PageSize; output.CurrentPage = parameters.Page; output.TotalRecord = totalRow; output.TotalPage = (totalRow - 1) / parameters.PageSize + 1; output.Data = _mapper.Map <IEnumerable <ProductSearchResultDTO> >(result); return(output); } else if (parameters.ProductTypeId == 7) { var result = await _repoWrapper.Product.GetListMaterials(parameters); var firstItem = result.FirstOrDefault(); int totalRow = (int)(firstItem?.TotalRows ?? 0); var output = new ProductPaggingDTO(); output.PageSize = parameters.PageSize; output.CurrentPage = parameters.Page; output.TotalRecord = totalRow; output.TotalPage = (totalRow - 1) / parameters.PageSize + 1; output.Data = _mapper.Map <IEnumerable <ProductSearchResultDTO> >(result); return(output); } else if (parameters.ProductTypeId == 11) { var result = await _repoWrapper.Product.GetListServices(parameters); var firstItem = result.FirstOrDefault(); int totalRow = (int)(firstItem?.TotalRows ?? 0); var output = new ProductPaggingDTO(); output.PageSize = parameters.PageSize; output.CurrentPage = parameters.Page; output.TotalRecord = totalRow; output.TotalPage = (totalRow - 1) / parameters.PageSize + 1; output.Data = _mapper.Map <IEnumerable <ProductSearchResultDTO> >(result); return(output); } else { var result = await _repoWrapper.Product.GetListProductPagging(parameters); var firstItem = result.FirstOrDefault(); int totalRow = (int)(firstItem?.TotalRows ?? 0); var output = new ProductPaggingDTO(); output.PageSize = parameters.PageSize; output.CurrentPage = parameters.Page; output.TotalRecord = totalRow; output.TotalPage = (totalRow - 1) / parameters.PageSize + 1; output.Data = _mapper.Map <IEnumerable <ProductSearchResultDTO> >(result); return(output); } }
public async Task <ProductPaggingDTO> GetListServiceByProductBrand(int page, int pageSize, int statusTypeId, int productTypeId, int productBrandId) { ProductPaggingDTO output = new ProductPaggingDTO(); string apiUrl = $"/api/v1/Product/GetListProduct"; string paramRequest = $"?Page={page}&PageSize={pageSize}&StatusTypeId={statusTypeId}&ProductTypeId={productTypeId}&ProductBrandId={productBrandId}"; var response = await _client.GetAsync(apiUrl + paramRequest); if (response.IsSuccessStatusCode) { string responseStream = await response.Content.ReadAsStringAsync(); output = JsonConvert.DeserializeObject <ProductPaggingDTO>(responseStream); } return(output); }
public async Task <ProductPaggingDTO> SearchProducts(int page = 0, int pageSize = 20, string query = "") { var output = new ProductPaggingDTO(); string apiUrl = $"/api/v1/Search/ElasticProductSearch"; string paramRequest = $"?page={page}&pageSize={pageSize}&search={query}"; var response = await _client.GetAsync(apiUrl + paramRequest); if (response.IsSuccessStatusCode) { string responseStream = await response.Content.ReadAsStringAsync(); output = JsonConvert.DeserializeObject <ProductPaggingDTO>(responseStream); } return(output); }
public async Task <ProductPaggingDTO> GetListProductPagging(ProductFilter model) { var output = new ProductPaggingDTO(); string apiUrl = $"/api/v1/Product/GetListProduct"; string paramRequest = $"?Page={model.Page}&PageSize={model.PageSize}&ProductTypeId={model.ProductTypeId}&ProductCategoryId={model.ProductCategoryId}&ProductBrandId={model.ProductBrandId}" + $"&StatusTypeId={model.StatusTypeId}&ProductManufactureId={model.ProductManufactureId}&ProductModelId={model.ProductModelId}&LocationId={model.LocationId}&PatchNum={model.PatchNum}" + $"&MainSystemId={model.MainSystemId}&StatusMachine={model.StatusMachine}"; var response = await _client.GetAsync(apiUrl + paramRequest); if (response.IsSuccessStatusCode) { string responseStream = await response.Content.ReadAsStringAsync(); output = JsonConvert.DeserializeObject <ProductPaggingDTO>(responseStream); } return(output); }
/// <summary> /// Get HomeBock Product /// </summary> /// <param name="productTypeId"></param> /// <param name="productCategoryId"></param> /// <returns></returns> public async Task <ProductPaggingDTO> GetHomeBlockProduct(int productTypeId, int productCategoryId) { ProductPaggingDTO output = new ProductPaggingDTO(); ProductFilter parameter = new ProductFilter(); parameter.Page = 1; parameter.PageSize = 10; parameter.StatusTypeId = 4; parameter.ProductTypeId = productTypeId; parameter.ProductCategoryId = productCategoryId; try { output = await _repoWrapper.Product.GetListProductPagging(parameter); } catch (Exception ex) { _logger.LogError($"HomeController- GetHomeBlockProduct {ex.ToString()}"); } return(output); }
public async Task <ProductPaggingDTO> GetLstProduct(string Keyword, int?page, int?pageSize, int?StatusTypeId, int?ProductTypeId, int?ProductCategoryId) { ProductPaggingDTO output = new ProductPaggingDTO(); var jwt = JsonConvert.DeserializeObject <SumProfileResponseDTO>(_httpContextAccessor.HttpContext.Request.Cookies["JWT"]); if (jwt != null) { _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt.JWT); string apiUrl = $"/api/v1/Product/GetLstProductShopMan"; string paramRequest = $"?Keyword={Keyword}&Page={page}&PageSize={pageSize}&StatusTypeId={StatusTypeId}&ProductTypeId={ProductTypeId}&ProductCategoryId={ProductCategoryId}&UserId={jwt.UserId}"; var response = await _client.GetAsync(apiUrl + paramRequest); if (response.IsSuccessStatusCode) { string responseStream = await response.Content.ReadAsStringAsync(); output = JsonConvert.DeserializeObject <ProductPaggingDTO>(responseStream); } } return(output); }
public async Task <IActionResult> DemandProduct() { ViewBag.CategoryMenuHeader = await GetCategoryMenu(); ViewBag.SubMenu656 = await _repoWrapper.ProductCategory.GetLstMenuByParentId(656); // máy công trình ViewBag.SubMenu1902 = await _repoWrapper.ProductCategory.GetLstMenuByParentId(1902); // xe hơi ViewBag.SubMenu669 = await _repoWrapper.ProductCategory.GetLstMenuByParentId(669); // xe tải chở hàng ProductPaggingDTO output = new ProductPaggingDTO(); ViewBag.ProductOfCate656 = await _repoWrapper.Product.GetListProductPagging(new ProductFilter { Page = 1, PageSize = 10, StatusTypeId = 4, ProductCategoryId = 656, ProductTypeId = 2 }); ViewBag.ProductOfCate1902 = await _repoWrapper.Product.GetListProductPagging(new ProductFilter { Page = 1, PageSize = 10, StatusTypeId = 4, ProductCategoryId = 1902, ProductTypeId = 2 }); ViewBag.ProductOfCate669 = await _repoWrapper.Product.GetListProductPagging(new ProductFilter { Page = 1, PageSize = 10, StatusTypeId = 4, ProductCategoryId = 669, ProductTypeId = 2 }); ViewBag.CategoryMenuTakeTop = await _repoWrapper.ProductCategory.GetLstMenuByParentId(654); ViewBag.CateMenus = await _repoWrapper.ProductCategory.GetProdCateTwoLevel(654); return(View()); }