示例#1
0
        public JsonResult AddProduct(SearchProductModel model)
        {
            var result = new JsonResultObject();
            var count  = 0;

            if (model.ValidateProductIDs)
            {
                count = ActivityBLL.Instance.Activity_AddProduct(model.ActID, model.ProductIDs);
            }
            else
            {
                if (model.ValidateBatUpdate)
                {
                    count = ActivityBLL.Instance.Activity_AddProduct(model.ActID, model.GetCFPath, model.BrandID, model.ProductID, model.ProductCode);
                }
                else
                {
                    result.msg = "批量添加的时候,最少要一个条件";
                }
            }
            if (count > 0)
            {
                result.status = true;
                result.msg    = "共操作" + count.ToString() + "条记录";
            }
            return(Json(result));
        }
        private void DoneButton_Click(object sender, EventArgs e)
        {
            var searchModel = new SearchProductModel()
            {
                Brand     = this.BrandAutoCompleteTextView.Text,
                Price     = (this.PriceMinEditText.Text != "") ? (decimal?)decimal.Parse(this.PriceMinEditText.Text) : null,
                PriceTo   = (this.PriceMaxEditText.Text != "") ? (decimal?)decimal.Parse(this.PriceMaxEditText.Text) : null,
                RAM       = (this.RAMMinEditText.Text != "") ? (int?)int.Parse(this.RAMMinEditText.Text) : null,
                RAMTo     = (this.RAMMaxEditText.Text != "") ? (int?)int.Parse(this.RAMMaxEditText.Text) : null,
                Year      = (this.YearMinEditText.Text != "") ? (int?)int.Parse(this.YearMinEditText.Text) : null,
                YearTo    = (this.YearMaxEditText.Text != "") ? (int?)int.Parse(this.YearMaxEditText.Text) : null,
                Battery   = (this.BatteryMinEditText.Text != "") ? (int?)int.Parse(this.BatteryMinEditText.Text) : null,
                BatteryTo = (this.BatteryMaxEditText.Text != "") ? (int?)int.Parse(this.BatteryMaxEditText.Text) : null,
                Camera    = (this.CameraMinEditText.Text != "") ? (int?)int.Parse(this.CameraMinEditText.Text) : null,
                CameraTo  = (this.CameraMaxEditText.Text != "") ? (int?)int.Parse(this.CameraMaxEditText.Text) : null,
                Memory    = (this.MemoryMinEditText.Text != "") ? (int?)int.Parse(this.MemoryMinEditText.Text) : null,
                MemoryTo  = (this.MemoryMaxEditText.Text != "") ? (int?)int.Parse(this.MemoryMaxEditText.Text) : null,
            };

            try
            {
                var resource = ProductAPIController.SearchProduct(searchModel).Result;
                this.GridView.Adapter = new ProductsAdapter(this.context, resource, Resource.Layout.ProductAdapterItem);
            }
            catch (Exception)
            {
                throw;
            }

            this.Dismiss();
        }
示例#3
0
        public DBResult InsertRecurringSearches(SearchProductModel entity)
        {
            DBResult result = new DBResult();

            using (var db = new LiteDatabase(AppRuntime.LiteDbConnectionString))
            {
                try
                {
                    var data = db.GetCollection <Schemas.Search.SearchProductModel>("RecurringSearches");

                    SearchProductModel searchItem = data.Find(Query.EQ("IdProduct", entity.IdProduct)).FirstOrDefault();

                    if (searchItem == null)
                    {
                        data.Insert(entity);
                    }

                    result.IsSucess = true;
                }
                catch (Exception ex)
                {
                    result.IsSucess = false;
                    result.Message  = ex.Message;
                }
            }
            return(result);
        }
示例#4
0
        /// <summary>
        ///     根据条件查询产品
        /// </summary>
        /// <param name="model">查询条件Model</param>
        /// <returns>Json数据</returns>
        public ActionResult Search(SearchProductModel model)
        {
            model.LanguageId = ACultureHelper.GetLanguageID;
            var result = this._productService.Search(model);

            return(this.Json(new { rows = result.Data, total = result.Data.TotalCount }, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public ApiResponse <ProductDetailsSummaryModel> GetAllProducts(SearchProductModel search)
        {
            var deviceNo = GetDeviceNo();
            var products = _productServices.GetAllProducts(search, deviceNo);

            return(ApiUtility.ApiSuccess <ProductDetailsSummaryModel>(products, "Search products using filter successfully"));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SearchProduct su = new SearchProduct(CurrentAdmin, CurrentLanguage.Code);

            model    = su.Model;
            callback = RequestTool.RequestString("callback");
        }
示例#7
0
        public ActionResult GetStoreProducts(SearchProductModel model)
        {
            PackageProductsViewModel returnModel = new PackageProductsViewModel();
            JObject response;

            if (model.PackageId.HasValue == false || (model.PackageId.HasValue == true && model.PackageId.Value == 0))
            {
                response = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi("api/Admin/SearchProducts", User, null, true, false, null, "ProductName=" + model.ProductName + "", "ProductPrice=" + model.ProductPrice, "CategoryName=" + model.CategoryName + "", "StoreId=" + model.StoreId));
                if (response is Error)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, (response as Error).ErrorMessage));
                }
                else
                {
                    returnModel.Products = response.GetValue("Result").SelectToken("Products").ToObject <List <PackageProductViewModel> >();
                }
            }
            else
            {
                response = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi("api/Packages/GetPackageProducts", User, null, true, false, null, "PackageId=" + model.PackageId, "StoreId=" + model.StoreId));

                if (response is Error)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, (response as Error).ErrorMessage));
                }
                else
                {
                    returnModel.Products = response.GetValue("Result").SelectToken("Products").ToObject <List <PackageProductViewModel> >();
                }
            }

            return(PartialView("_PackageProducts", returnModel));
        }
示例#8
0
        public IList <Product> GetProducts(SearchProductModel searchProduct)
        {
            if (!searchProduct.Validate())
            {
                throw new ArgumentException("SearchProductModel didn't pass validation");
            }

            return(_context.Query <Product>($@"
                   SELECT
                        ProductId
                        ,ProductName
                        ,ProductDescription
                        ,ProductPrice
                        ,ImageId
                        ,AddedDate
                    FROM
                        Products
                    {CreateQuery(searchProduct)}
                   ORDER BY {searchProduct.OrderBy}{(searchProduct.IsDesc ? " DESC" : string.Empty)}
                    OFFSET @skip ROWS
                    FETCH NEXT @take ROWS ONLY
                ", new
            {
                skip = searchProduct.Skip,
                take = searchProduct.Take
            }
                                            ).ToList());
        }
示例#9
0
        public async Task <IActionResult> Search(SearchProductModel instance)
        {
            var siteUri = new Uri("http://localhost:5002/api/Products/Search");

            // ... Use HttpClient.
            using (HttpClient client = new HttpClient())
            {
                var content     = JsonConvert.SerializeObject(instance);
                var buffer      = System.Text.Encoding.UTF8.GetBytes(content);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                using (HttpResponseMessage response = await client.PostAsync(
                           siteUri, byteContent))
                {
                    using (HttpContent cont = response.Content)
                    {
                        // ... Read the string.
                        string result = await cont.ReadAsStringAsync();

                        var products = JsonConvert.DeserializeObject <List <ProductModel> >(result);
                        return(RedirectToAction("IndexAsync", new { matchedProducts = result }));
                    }
                }
            }
        }
示例#10
0
 public ProductDetailsSummaryModel GetAllProducts(SearchProductModel search, string deviceNo)
 {
     try
     {
         ProductDetailsSummaryModel             objProduct     = new ProductDetailsSummaryModel();
         System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
         string host = (string)settingsReader.GetValue("WebHostName", typeof(String));
         using (var productContract = new ProductContract())
         {
             var products = productContract.GetProducts(search, deviceNo, false);
             objProduct.ProductList      = products;
             objProduct.FilterCategories = productContract.GetFilterCategory(products);
             objProduct.FilterBrands     = productContract.GetFilterBrand(products);
             objProduct.FilterArtists    = productContract.GetFilterArtists(products);
             objProduct.FilterVendors    = productContract.GetFilterVendors(products);
             objProduct.ProductList.ForEach(x =>
             {
                 x.ProductImages.ForEach(y =>
                 {
                     y.GalleryImageURL = y.GalleryImageURL.Replace("..", host);
                     y.ImageURL        = y.ImageURL.Replace("..", host);
                     y.ThumbImageURL   = y.ThumbImageURL.Replace("..", host);
                 });
             });
             if (objProduct.FilterCategories != null)
             {
                 objProduct.FilterCategories.ForEach(x =>
                 {
                     x.PictureUrl = x.PictureUrl.Replace("..", host);
                 });
             }
             if (objProduct.FilterBrands != null)
             {
                 objProduct.FilterBrands.ForEach(x =>
                 {
                     x.PictureURL = x.PictureURL.Replace("..", host);
                 });
             }
             if (objProduct.FilterArtists != null)
             {
                 objProduct.FilterArtists.ForEach(x =>
                 {
                     x.PictureURL = x.PictureURL.Replace("..", host);
                 });
             }
             if (objProduct.FilterVendors != null)
             {
                 objProduct.FilterVendors.ForEach(x =>
                 {
                     x.PictureURL = x.PictureURL.Replace("..", host);
                 });
             }
             return(objProduct);
         }
     }
     catch
     {
         throw;
     }
 }
示例#11
0
 public List <ProductSummaryModel> GetFeaturedProducts(CurrencyTypeName currencyTypeName, string deviceNo)
 {
     try
     {
         System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
         string host   = (string)settingsReader.GetValue("WebHostName", typeof(String));
         var    search = new SearchProductModel
         {
             CurrencyName = currencyTypeName,
         };
         using (var productContract = new ProductContract())
         {
             var products = productContract.GetProducts(search, deviceNo, true);
             products.ForEach(x =>
             {
                 x.ProductImages.ForEach(y =>
                 {
                     y.GalleryImageURL = y.GalleryImageURL.Replace("..", host);
                     y.ImageURL        = y.ImageURL.Replace("..", host);
                     y.ThumbImageURL   = y.ThumbImageURL.Replace("..", host);
                 });
             });
             return(products);
         }
     }
     catch
     {
         throw;
     }
 }
示例#12
0
        public JsonResult GetAllProductsFromSupplier(string supplierID)
        {
            SearchProductModel productPerSupplier = new SearchProductModel();
            //productPerSupplier.m_add_new_product = false;
            //productPerSupplier.m_add_new_shipment = true;

            long suppliershipid = Convert.ToInt32(supplierID);

            string SQL = "SELECT * FROM PRODUCT INNER JOIN ";

            SQL += " SHIPMENT_PRODUCT_DETAIL ON PRODUCT.productID = SHIPMENT_PRODUCT_DETAIL.productID INNER JOIN ";
            SQL += " SHIPMENT_DETAIL ON SHIPMENT_PRODUCT_DETAIL.shipmentDetailsID = SHIPMENT_DETAIL.shipmentDetailsID INNER JOIN ";
            SQL += " SHIPMENT ON SHIPMENT_DETAIL.shipmentID = SHIPMENT.shipmentID ";
            SQL += " WHERE SHIPMENT.shipmentID = " + suppliershipid + "";


            using (var dbContext = new WH01Entities())
            {
                var products = dbContext.PRODUCT.SqlQuery(SQL).ToList();
            }



            //if (supplierShipmentID != null)
            //{
            //    using (var getProductPerSupplier = new WH01Entities())
            //    {
            //        var cptoadd = (from j in getProductPerSupplier.SHIPMENT_PRODUCT_DETAIL
            //                       where j.SHIPMENT_DETAIL.SHIPMENT.shipmentID ==
            //                       select new SearchProductModel()
            //                       {
            //                           m_productName = j.SUPPLIER2.
            //                           m_productDescriptionLong = j.PRODUCT_DESCRIPTION.productDescLong,
            //                           m_productColor = j.productColor,
            //                           m_productPrice = j.productPrice,
            //                           m_productSize = j.productSize,
            //                           m_productWeight = j.productWeight,
            //                           m_productSerialNumber = j.PRODUCT_DESCRIPTION.PRODUCT.productSerialNumber

            //                       }).SingleOrDefault();

            //        addProduct.m_productName = cptoadd.m_productName;
            //        addProduct.m_productDescriptionLong = cptoadd.m_productDescriptionLong;
            //        addProduct.m_productColor = cptoadd.m_productColor;
            //        addProduct.m_productPrice = cptoadd.m_productPrice;
            //        addProduct.m_productSize = cptoadd.m_productSize;
            //        addProduct.m_productWeight = cptoadd.m_productWeight;
            //        addProduct.m_productSerialNumber = cptoadd.m_productSerialNumber;

            //    }


            //}



            return(Json(productPerSupplier, JsonRequestBehavior.AllowGet));
        }
示例#13
0
        public SearchProductModel GetProd([FromBody] SearchRQModel list_rq)
        {
            Website.Instance.logger.Info($"WMS GetProd Start! B2D Xid:{list_rq.company_xid}");

            var prods = new SearchProductModel();

            prods = SearchRepository.GetProdList(list_rq);

            return(prods);
        }
 public IHttpActionResult SearchProducts(SearchProductModel model)
 {
     return(RunInSafe(() =>
     {
         var data = _productService.SearchProducts(model);
         tebResponse.Data = data.Result;
         tebResponse.IsSuccess = true;
         return Ok(tebResponse);
     }));
 }
示例#15
0
        public ActionResult GetProductList(Int64 Id)
        {
            ViewBag.SubCategory = Convert.ToString(_productSubCategoryRepository.FindBy(x => x.ProductSubCategoryId == Id).Select(x => x.ProductSubCategoryName).FirstOrDefault()).ToUpper();
            SearchProductModel model = new SearchProductModel();

            model.SubCategoryId   = Id;
            model.getProductModel = _productRepository.GetProductList().Where(x => x.ProductSubCategoryId == Id && x.Status == (int)Status.Active && x.IsDeleted == false).ToList();

            return(View(model));
        }
示例#16
0
        public List <ProductSummaryModel> GetProducts(SearchProductModel search, string deviceNo, bool isFeaturedProducts)
        {
            try
            {
                CurrencyTypeName currencyTypeName = search.CurrencyName;
                using (var dataContext = new BrownBagDataEntities())
                {
                    var isExclusiveUser = CheckExclusiveUser(dataContext, deviceNo.Trim());
                    var ratings         = dataContext.Ratings.GroupBy(g => g.ProductID).Select(s2 => new { ProductId = s2.Key, Average = s2.Average(p => p.Rating1 ?? 0), ReviewCount = s2.Where(w => string.IsNullOrEmpty(w.Review)).Count() }).ToList();
                    var products        = dataContext.Products
                                          .Where(w => (isFeaturedProducts == false || w.IsRental == (isFeaturedProducts == true ? 1 : 0)) &&
                                                 w.Published == 1 &&
                                                 (isExclusiveUser == true || w.IsExclusive == (isExclusiveUser == true ? 1 : 0)) &&
                                                 (search.CategoryIds.Count == 0 || (search.CategoryIds.Any(k => k == (w.CategoryID ?? 0)))) &&
                                                 (search.BrandIds.Count == 0 || (search.BrandIds.Any(k => k == (w.ManufacturerID ?? 0)))) &&
                                                 (search.ArtistIds.Count == 0 || (search.ArtistIds.Any(k => k == (w.ArtistID ?? 0)))) &&
                                                 (search.VendorIds.Count == 0 || (search.VendorIds.Any(k => k == (w.VendorID ?? 0)))) &&
                                                 (search.ProductSearchText == null || search.ProductSearchText == "" || w.FullDescription.Contains(search.ProductSearchText) || w.ShortDescription.Contains(search.ProductSearchText) || w.ProductName.Contains(search.ProductSearchText))
                                                 ).AsEnumerable()
                                          .Select(s => new ProductSummaryModel
                    {
                        Id               = s.Id,
                        CategoryId       = s.CategoryID ?? 0,
                        ManufacturerId   = s.ManufacturerID ?? 0,
                        ArtistId         = s.ArtistID ?? 0,
                        VendorId         = s.VendorID ?? 0,
                        CurrencyType     = currencyTypeName.ToString(),
                        FullDescription  = s.FullDescription ?? "",
                        ProductName      = s.ProductName ?? "",
                        ShortDescription = s.ShortDescription ?? "",
                        Discount         = s.Discount ?? 0,
                        Stock            = s.Stock ?? 0,
                        IsExclusive      = (s.IsExclusive ?? 0) == 1 ? true : false,
                        Price            = (currencyTypeName == CurrencyTypeName.INR) ? s.CP_INR ?? 0 : (currencyTypeName == CurrencyTypeName.USD) ? s.CP_USD ?? 0 : (currencyTypeName == CurrencyTypeName.EURO) ? s.CP_Euro ?? 0 : s.CP_GBP ?? 0,
                        ProductImages    = dataContext.ProductImages.Where(x => x.ProductID == s.Id).Select(s1 => new Model.ProductImage
                        {
                            Id = s1.Id,
                            GalleryImageURL = s1.GalleryImageURL,
                            ImageURL        = s1.ImageURL,
                            ThumbImageURL   = s1.ThumbImageURL,
                            Sequences       = s1.Sequences ?? 0
                        }).OrderBy(o => o.Sequences).ToList(),

                        Rating      = ratings.Where(w1 => w1.ProductId == s.Id).Count() > 0 ? ratings.Where(w1 => w1.ProductId == s.Id).FirstOrDefault().Average : 0,
                        ReviewCount = ratings.Where(w1 => w1.ProductId == s.Id).Count() > 0 ? ratings.Where(w1 => w1.ProductId == s.Id).FirstOrDefault().ReviewCount : 0,
                    })
                                          .ToList();
                    return(products);
                }
            }
            catch
            {
                throw;
            }
        }
示例#17
0
        public JsonResult ChangeProductPicture(string picture)
        {
            SearchProductModel addProduct = new SearchProductModel();

            addProduct.m_add_new_product  = true;
            addProduct.m_add_new_shipment = false;
            addProduct.m_productPicture   = picture;



            return(Json(addProduct, JsonRequestBehavior.AllowGet));
        }
示例#18
0
        public ActionResult _GetProductList(SearchProductModel model)
        {
            var query = _productRepository.GetProductList().Where(x => x.ProductSubCategoryId == model.SubCategoryId && x.Status == (int)Status.Active && x.IsDeleted == false);

            if (!string.IsNullOrEmpty(model.Search))
            {
                query = query.Where(x => x.ProductName.Contains(model.Search));
            }
            model.getProductModel = query.ToList();

            return(PartialView(model));
        }
示例#19
0
        public async Task <PaginatedResult <Product> > SearchPublicAsync(SearchProductModel req)
        {
            // filter
            var queryObject = QueryObject <Product> .Empty;

            if (!string.IsNullOrWhiteSpace(req.Keyword))
            {
                var keyword = req.Keyword;
                queryObject.And(new ProductQueryObjects.ContainsKeyword(keyword));
            }

            // filter by category
            if (!string.IsNullOrWhiteSpace(req.ProductCategoryName))
            {
                var keyword = req.ProductCategoryName;
                queryObject.And(new ProductQueryObjects.FilterByCategory(keyword));
            }

            // filter by Owner
            if (!string.IsNullOrWhiteSpace(req.OwnerName))
            {
                var keyword = req.OwnerName;
                queryObject.And(new ProductQueryObjects.FilterBySeller(keyword));
            }

            // filter by MinPrice & MaxPrice
            if (req.MaxPrice == 0)
            {
                req.MaxPrice = decimal.MaxValue;
            }
            if (req.MinPrice < 0)
            {
                req.MinPrice = decimal.Zero;
            }
            queryObject.And(new ProductQueryObjects.FilterByPrice(req.MinPrice, req.MaxPrice));

            // orderby
            if (!req.Sort.Any())
            {
                req.Sort.Add(new SortItem {
                    FieldName = nameof(Product.IdentityKey)
                });
            }

            req.Sort.ForEach(x => queryObject.AddOrderBy(x.FieldName, x.IsDescending));

            // execute
            var result = await _genericRepo.SearchAsync(queryObject, req.Pagination, x => x.Include(m => m.Category).Include(m => m.Owner).Include(m => m.Photos));

            return(result);
        }
示例#20
0
        public PartialViewResult SearchProduct(int?actid, SearchProductModel model)
        {
            var sindex = 0;

            int.TryParse(Request["sindex"], out sindex);
            model.pageindex = sindex > 0 ? sindex : 1;
            var str = new StringBuilder(" 1=1 ");

            str.AppendFormat(" AND NOT EXISTS(SELECT * FROM ProductActivity pa where pa.ProductID = p.ProductID and pa.ActID ={0})", actid);
            var cfid = 0;

            if (model.CF3 > 0)
            {
                cfid = model.CF3;
            }
            else if (model.CF2 > 0)
            {
                cfid = model.CF2;
            }
            else if (model.CF1 > 0)
            {
                cfid = model.CF1;
            }
            if (cfid > 0)
            {
                var cf = ClassificationBLL.Instance.Classification_Get(cfid);
                if (!string.IsNullOrWhiteSpace(cf.Path))
                {
                    str.AppendFormat(" AND EXISTS (SELECT 1 FROM ProductClassification AS pc WHERE pc.ProductID =p.ProductID AND  pc.CFPath LIKE '{0}%')", cf.Path);
                }
            }
            if (model.ProductID > 0)
            {
                str.AppendFormat(" AND p.ProductID={0} ", model.ProductID);
            }
            if (!string.IsNullOrWhiteSpace(model.ProductCode))
            {
                str.AppendFormat(" AND p.ProductCode='{0}'", model.ProductCode);
            }
            if (model.BrandID > 0)
            {
                str.AppendFormat(" AND p.BrandID={0} ", model.BrandID);
            }
            int recordCount = 0;
            var productlist = ProductBLL.Instance.Product_GetList(model.pageindex, model.pagesize, "0", str.ToString(), out recordCount);
            var paged       = new PagedList <ProductInfo>(productlist, model.pageindex, model.pagesize, recordCount);

            ViewBag.SearchProductList = paged;
            ViewBag.ActID             = actid;
            return(PartialView("_PartialSearchProduct"));
        }
示例#21
0
 private static bool ChechSerach(SearchProductModel model, Product product)
 {
     return(((model.Price == null) || ((double)model.Price < (double)product.Price)) &&
            ((model.PriceTo == null) || ((double)model.PriceTo > (double)product.Price)) &&
            ((model.RAM == null) || (model.RAM < product.RAM)) &&
            ((model.RAMTo == null) || (model.RAMTo > product.RAM)) &&
            ((model.Year == null) || (model.Year < product.Year)) &&
            ((model.YearTo == null) || (model.YearTo > product.Year)) &&
            ((model.Battery == null) || (model.Battery < product.Battery)) &&
            ((model.BatteryTo == null) || (model.BatteryTo > product.Battery)) &&
            ((model.Camera == null) || (model.Camera > product.Camera)) &&
            ((model.CameraTo == null) || (model.CameraTo < product.Camera)) &&
            ((model.Memory == null) || (model.Memory > product.Memory)) &&
            ((model.MemoryTo == null) || (model.MemoryTo < product.Memory)) &&
            ((model.Brand == "") || (product.Brand.IndexOf(model.Brand) != -1)));
 }
示例#22
0
        public ActionResult SearchProductResults(SearchProductModel model)
        {
            SearchProductsViewModel returnModel = new SearchProductsViewModel();
            var response = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi("api/Admin/SearchProducts", User, null, true, false, null, "ProductName=" + model.ProductName + "", "ProductPrice=" + model.ProductPrice, "CategoryName=" + model.CategoryName + "", "StoreId=" + Global.StoreId, "CatId=null"));

            if (response is Error)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, (response as Error).ErrorMessage));
            }
            else
            {
                returnModel = response.GetValue("Result").ToObject <SearchProductsViewModel>();
            }
            returnModel.SetSharedData(User);
            return(PartialView("_SearchProductResults", returnModel));
        }
示例#23
0
        public static async Task <List <Product> > SearchProduct(SearchProductModel searchProductModel)
        {
            Uri siteUri = new Uri("http://192.168.6.30:5002/api/Products/Search/");

            using (HttpClient client = new HttpClient())
            {
                var content     = JsonConvert.SerializeObject(searchProductModel);
                var buffer      = System.Text.Encoding.UTF8.GetBytes(content);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                var response = client.PostAsync(siteUri, byteContent).Result;
                var res      = response.Content.ReadAsStringAsync().Result;
                var products = JsonConvert.DeserializeObject <List <Product> >(res);

                return(products);
            }
        }
示例#24
0
        public void ProductService_Search_Test()
        {
            var model = new SearchProductModel
            {
                PagedIndex = 0,
                PagedSize  = 10,
                //LanguageId = 1,
                ProductId = 1
            };

            var result = this._productService.Search(model);

            Assert.IsTrue(result.IsValid);
            if (model.ProductId.HasValue)
            {
                Assert.IsTrue(result.Data != null);
            }
        }
示例#25
0
 public IActionResult Search(SearchProductModel form)
 {
     try
     {
         // form.code = form.code.ToLower().Trim() ?? "";
         form.name = form.name.ToLower().Trim() ?? "";
         var data = _db.Product
                    .Include(p => p.Type).Include(p => p.Manufacturer).Include(p => p.Category)
                    .Where(d =>
                           // d.Barcode.ToLower().Contains(form.code) &&
                           d.Name.ToLower().Contains(form.name))
                    .Select(d => new ProductModel(d));
         return(Ok(new { Success = true, Data = data }));
     }
     catch (Exception e)
     {
         _logger.logError(e);
     }
     return(Ok(new { Success = false }));
 }
示例#26
0
        public ActionResult NewProduct()
        {
            SearchProductModel addProduct = new SearchProductModel();

            addProduct.m_add_new_product  = true;
            addProduct.m_add_new_shipment = false;

            using (var searchPhrase = new WH01Entities())
            {
                var copiedProductsResult = from i in searchPhrase.PRODUCT_DESCRIPTION
                                           where i.prodctCopied == true
                                           select i;

                addProduct.copiedProducts = new Dictionary <long, string>();
                foreach (PRODUCT_DESCRIPTION pdesc in copiedProductsResult)
                {
                    addProduct.copiedProducts.Add(pdesc.productID, pdesc.PRODUCT.productName);
                }
            }


            return(View("NewProduct", addProduct));
        }
示例#27
0
        public ActionResult SearchProduct()
        {
            SearchProductModel returnModel = new SearchProductModel();

            var responseStores = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi("api/GetAllStores", User, GetRequest: true));

            if (responseStores == null || responseStores is Error)
            {
            }
            else
            {
                var Stores = responseStores.GetValue("Result").ToObject <List <StoreBindingModel> >();
                IEnumerable <SelectListItem> selectList = from store in Stores
                                                          select new SelectListItem
                {
                    Selected = false,
                    Text     = store.Name,
                    Value    = store.Id.ToString()
                };
                Stores.Insert(0, new StoreBindingModel {
                    Id = 0, Name = "All"
                });

                returnModel.StoreOptions = new SelectList(selectList);
            }

            returnModel.SetSharedData(User);
            //returnModel. returnModel.StoreId
            if (returnModel.Role == RoleTypes.SubAdmin)
            {
                returnModel.StoreId = (returnModel as BaseViewModel).StoreId;
            }



            return(PartialView("_SearchProduct", returnModel));
        }
示例#28
0
        public JsonResult PopulateCopiedProduct(long?productid)
        {
            SearchProductModel addProduct = new SearchProductModel();

            addProduct.m_add_new_product  = true;
            addProduct.m_add_new_shipment = false;

            if (productid != null)
            {
                using (var searchCopiedProduct = new WH01Entities())
                {
                    var cptoadd = (from j in searchCopiedProduct.PRODUCT_DESCRIPTION_DETAIL
                                   where j.PRODUCT_DESCRIPTION.PRODUCT.productID == productid
                                   select new SearchProductModel()
                    {
                        m_productName = j.PRODUCT_DESCRIPTION.PRODUCT.productName,
                        m_productDescriptionLong = j.PRODUCT_DESCRIPTION.productDescLong,
                        m_productColor = j.productColor,
                        m_productPrice = j.productPrice,
                        m_productSize = j.productSize,
                        m_productWeight = j.productWeight,
                        m_productSerialNumber = j.PRODUCT_DESCRIPTION.PRODUCT.productSerialNumber
                    }).SingleOrDefault();

                    addProduct.m_productName            = cptoadd.m_productName;
                    addProduct.m_productDescriptionLong = cptoadd.m_productDescriptionLong;
                    addProduct.m_productColor           = cptoadd.m_productColor;
                    addProduct.m_productPrice           = cptoadd.m_productPrice;
                    addProduct.m_productSize            = cptoadd.m_productSize;
                    addProduct.m_productWeight          = cptoadd.m_productWeight;
                    addProduct.m_productSerialNumber    = cptoadd.m_productSerialNumber;
                }
            }

            return(Json(addProduct, JsonRequestBehavior.AllowGet));
        }
示例#29
0
        public async Task <ActionResult> ProductList(DataSourceRequest command, ProductSearchViewModel model)
        {
            var categoryIds = model.SearchCategoryId > 0 ? new List <int> {
                model.SearchCategoryId
            } : null;
            ////include subcategories
            //if (model.SearchIncludeSubCategories && model.SearchCategoryId > 0)
            //    categoryIds.AddRange(GetChildCategoryIds(model.SearchCategoryId));

            bool?overridePublished = null;

            if (model.SearchPublishedId == 1)
            {
                overridePublished = true;
            }
            else if (model.SearchPublishedId == 2)
            {
                overridePublished = false;
            }

            SearchProductModel searchmodel = new SearchProductModel
            {
                categoryIds       = categoryIds,
                manufacturerId    = model.SearchManufacturerId,
                storeId           = model.SearchStoreId,
                vendorId          = model.SearchVendorId,
                warehouseId       = model.SearchWarehouseId,
                productType       = model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null,
                keywords          = model.SearchProductName,
                pageIndex         = command.Page - 1,
                pageSize          = command.PageSize,
                showHidden        = true,
                overridePublished = overridePublished
            };
            TEBApiResponse apiResponse = await Post <SearchProductModel>("/Product/SearchProducts", searchmodel);

            if (apiResponse.IsSuccess)
            {
                try
                {
                    List <Product>      listproducts = JsonConvert.DeserializeObject <List <Product> >(Convert.ToString(apiResponse.Data));
                    PagedList <Product> products     = new PagedList <Product>(listproducts, 0, 10);
                    var gridModel = new DataSourceResult();
                    gridModel.Data = products.Select(x =>
                    {
                        var productModel = ProductMapping.ModelToView(x); // x.ToModel();
                                                                          //little performance optimization: ensure that "FullDescription" is not returned
                        productModel.FullDescription = "";

                        ////picture
                        //var defaultProductPicture = _pictureService.GetPicturesByProductId(x.Id, 1).FirstOrDefault();
                        //productModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultProductPicture, 75, true);
                        ////product type
                        //productModel.ProductTypeName = x.ProductType.GetLocalizedEnum(_localizationService, _workContext);
                        ////friendly stock qantity
                        ////if a simple product AND "manage inventory" is "Track inventory", then display
                        //if (x.ProductType == ProductType.SimpleProduct && x.ManageInventoryMethod == ManageInventoryMethod.ManageStock)
                        //    productModel.StockQuantityStr = x.GetTotalStockQuantity().ToString();

                        return(productModel);
                    });
                    gridModel.Total = products.TotalCount;

                    return(Json(gridModel));
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return(Json(0));
        }
示例#30
0
 public static async Task <List <Product> > SearchProduct(SearchProductModel searchProductModel)
 {
     return(ProductDataBase.Select(a => a.Value).Where(a => ChechSerach(searchProductModel, a)).ToList());
 }