示例#1
0
        private void GetNewestProduct()
        {
            WebService.AnperoService service      = new WebService.AnperoService();
            WebService.SearchResult  searchResult = new WebService.SearchResult();
            int shortCacheTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["shortCacheTime"]);

            if (HttpRuntime.Cache["newestProduct"] != null)
            {
                searchResult = (WebService.SearchResult)HttpRuntime.Cache["newestProduct"];
            }
            else
            {
                searchResult = service.SearchProduct(StoreID, TokenKey, "", "", "", 1, 999999999, 1, 4, "", SearchOrder.TimeDesc, 0, string.Empty);
                if (searchResult != null)
                {
                    HttpRuntime.Cache.Insert("newestProduct", searchResult, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero);
                }
            }

            ViewData["newestProduct"] = searchResult;
        }
示例#2
0
        public ActionResult ParentCategory(int id)
        {
            string pageQuery = Request.QueryString["page"];
            int    page      = 1;

            if (!string.IsNullOrEmpty(pageQuery))
            {
                page = Convert.ToInt32(pageQuery);
            }
            WebService.AnperoService sv = new WebService.AnperoService();
            WebService.SearchResult  rs = sv.GetProductByParentCategory(StoreID, TokenKey, id, page, 14, 0);
            ViewData["productList"] = rs;
            ViewBag.page            = Anpero.Paging.setUpPagedV2(page, 14, rs.ResultCount, 10, "?page=");
            ViewBag.isParent        = "1";
            if (rs != null && rs.Item.Length > 0)
            {
                ViewBag.Title = rs.Item[0].ParentCatName;
            }
            SetupCommonProduct();
            return(View("Category"));
        }
        public ActionResult Search(string category, string keyword)
        {
            string pageQuery = Request.QueryString["page"];
            int    page      = 1;

            if (!string.IsNullOrEmpty(pageQuery))
            {
                page = Convert.ToInt32(pageQuery);
            }
            WebService.AnperoService sv = new WebService.AnperoService();
            WebService.SearchResult  rs = sv.SearchProduct(StoreID, TokenKey, category, "", "", 0, 999999999, page, 14, keyword, SearchOrder.NameDesc, 0);
            ViewData["productList"] = rs;
            ViewBag.page            = Anpero.Paging.setUpPagedV2(page, 14, rs.ResultCount, 10, "?page=");
            if (rs != null && rs.Item.Length > 0)
            {
                ViewBag.Title = rs.Item[0].CatName;
            }

            SetupCommonProduct();

            return(View("Category"));
        }
        public ActionResult ParentCategory(int id)
        {
            string pageQuery = Request.QueryString["page"];
            int    page      = 1;

            if (!string.IsNullOrEmpty(pageQuery))
            {
                page = Convert.ToInt32(pageQuery);
            }
            WebService.AnperoService sv = new WebService.AnperoService();
            WebService.SearchResult  rs = sv.GetProductByParentCategory(StoreID, TokenKey, id, page, 14, 0);
            ViewData["productList"] = rs;
            ViewBag.page            = Anpero.Paging.setUpPagedV2(page, 14, rs.ResultCount, 10, "?page=");
            ViewBag.isParent        = "1";
            ProductCategory pc = CommontInfo.ProductCategoryList.Where(x => x.Id == id).FirstOrDefault();

            if (pc != null)
            {
                ViewBag.Title = pc.Name;
                ViewBag.Desc  = pc.Description;
            }
            SetupCommonProduct();
            return(View("Category"));
        }
示例#5
0
        public ActionResult Sales()
        {
            string pageQuery = Request.QueryString["page"];
            int    page      = 1;

            if (!string.IsNullOrEmpty(pageQuery))
            {
                page = Convert.ToInt32(pageQuery);
            }

            WebService.SearchResult  rs     = new WebService.SearchResult();
            WebService.ProductItem[] prList = service.GetSaleProduct(StoreID, TokenKey);
            rs.Item                 = prList;
            rs.ResultCount          = prList == null?0: prList.Count();
            ViewData["productList"] = rs;
            ViewBag.pageName        = "Sản phẩm khuyến mại";
            if (rs != null && rs.Item.Length > 0)
            {
                ViewBag.Title    = "Sản phẩm khuyến mại";
                ViewBag.isParent = "0";
            }

            return(View("List"));
        }
示例#6
0
        public void ProcessRequest(HttpContext context)
        {
            string  rs      = "";
            string  op      = context.Request["op"];
            string  captcha = context.Request["captcha"];
            Boolean valid   = true;

            if (String.IsNullOrEmpty(captcha))
            {
                valid = false;
                rs    = "Vui lòng click vào ô kiểm tra";
            }
            if (valid)
            {
                int    st       = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["storeID"]);
                string TokenKey = System.Configuration.ConfigurationManager.AppSettings["storeTokenKey"];
                switch (op)
                {
                case "searchProduct":
                {
                    WebService.AnperoService sv = new WebService.AnperoService();
                    string order          = context.Request["order"];
                    string category       = context.Request["cat"];
                    string parentCategory = context.Request["ParentCat"];
                    WebService.SearchResult relateProduct = sv.SearchProduct(st, TokenKey, "", parentCategory, "", 0, 9999999, 1, 15, "", order, 0, string.Empty);
                    if (relateProduct.Item.Length > 0)
                    {
                        foreach (var item in relateProduct.Item)
                        {
                            rs += "<li class=\"item col-lg-4 col-md-4 col-sm-4 col-xs-6\">";
                            rs += "<div class=\"product-image\">";
                            rs += "<a href=\"" + Anpero.StringHelpper.GetProductLink(item.PrName, item.Id) + "\">";
                            rs += "<img class=\"small-image\" src=\"" + item.Images + "\">";
                            rs += "</a>";
                            rs += "</div>";
                            rs += "<div class=\"product-shop\">";
                            rs += "<h2 class=\"product-name\">";
                            rs += "<a href=\"" + Anpero.StringHelpper.GetProductLink(item.PrName, item.Id) + "\">" + item.PrName + "</a>";
                            rs += "</h2>";
                            rs += "<div class=\"desc std\">";
                            rs += "<p>" + item.ShortDesc + "</p>";
                            rs += " <p><a class=\"link-learn\"  href=\"" + Anpero.StringHelpper.GetProductLink(item.PrName, item.Id) + "\">Chi tiết</a></p>";
                            rs += "</div>";
                            rs += "<div class=\"price-box\"><p class=\"old-price\"> <span class=\"price-label\"></span><span class=\"price\">" + Anpero.StringHelpper.ConVertToMoneyFormatInt(item.Price) + "</span></p></div>";
                            rs += "<div class=\"actions\">";
                            rs += "<button class=\"button btn-cart ajx-cart\" type=\"button\"><span>Mua ngay</span></button>";
                            rs += "<span class=\"add-to-links\"><a class=\"button link-wishlist\" href=\"#\"><span>Thêm vào giỏ hàng</span></a></span>";
                            rs += "</div></div>";
                            rs += "</li>";
                        }
                    }
                    break;
                }

                case "CreateOrder":
                {
                    string name        = context.Request["name"];
                    string email       = context.Request["email"];
                    string phone       = context.Request["phone"];
                    string address     = context.Request["address"];
                    string ProductList = context.Request["ProductList"];

                    int shipingFee = 0;
                    try
                    {
                        shipingFee = Convert.ToInt32(context.Request["shipingFee"]);
                    }
                    catch (Exception)
                    {
                    }
                    string detail         = context.Request["detail"];
                    int    paymentMethod  = 0;
                    int    shippingMethod = 0;
                    try
                    {
                        paymentMethod = Convert.ToInt32(context.Request["PayMentType"]);
                    }
                    catch (Exception)
                    {
                        paymentMethod = 4;
                    }
                    try
                    {
                        shippingMethod = Convert.ToInt32(context.Request["shippingMethod"]);
                    }
                    catch (Exception)
                    {
                        shippingMethod = 1;
                    }
                    WebService.AnperoService sv = new WebService.AnperoService();
                    int rs2 = sv.AddOrder(st, TokenKey, captcha, name, email, phone, address, ProductList, shipingFee, shippingMethod, paymentMethod, detail);
                    if (rs2 > 0)
                    {
                        rs = rs2.ToString();
                    }
                    if (rs2 == -1)
                    {
                        rs = "Số điện thoại không đúng định dạng";
                    }
                    if (rs2 == -2)
                    {
                        rs = "Vui lòng kick vào ô kiểm tra";
                    }
                    break;
                }

                case "sendContact":
                {
                    string name    = context.Request["name"];
                    string email   = context.Request["email"];
                    string phone   = context.Request["phone"];
                    string address = context.Request["address"];
                    string detail  = context.Request["message"];

                    WebService.AnperoService sv = new WebService.AnperoService();
                    rs = sv.addContact(st, TokenKey, name, email, phone, address, detail, HttpContext.Current.Request.UserHostAddress, captcha).ToString();
                    break;
                }

                default:
                    break;
                }
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(rs);
        }
        public ActionResult Search(string parentCat, string scat, int province, int district, int acr, int priceRank)
        {
            double pricefrom   = 0;
            double friceTo     = 5000000000;
            int    acreageFrom = 0;
            int    acreageTo   = 999999;

            #region calc priceRank
            switch (priceRank)
            {
            case 1:
                pricefrom = 3000000;
                friceTo   = 5000000;
                break;

            case 2:
                pricefrom = 5000000;
                friceTo   = 10000000;
                break;

            case 3:
                pricefrom = 10000000;
                friceTo   = 40000000;
                break;

            case 4:
                pricefrom = 40000000;
                friceTo   = 500000000;
                break;

            case 5:
                pricefrom = 500000000;
                friceTo   = 800000000;
                break;

            case 6:
                pricefrom = 1000000000;
                friceTo   = 2000000000;
                break;

            case 7:
                pricefrom = 1000000000;
                friceTo   = 2000000000;
                break;

            case 8:
                pricefrom = 3000000000;
                friceTo   = 5000000000;
                break;

            case 9:
                pricefrom = 5000000000;
                friceTo   = 7000000000;
                break;

            case 10:
                pricefrom = 7000000000;
                friceTo   = 10000000000;
                break;

            case 11:
                pricefrom = 10000000000;
                friceTo   = 20000000000;
                break;

            case 12:
                pricefrom = 20000000000;
                friceTo   = 30000000000;
                break;

            default:
                break;
            }
            #endregion calc priceRank
            #region calc acreage
            switch (acr)
            {
            case 1:
                acreageTo = 30;
                break;

            case 2:
                acreageFrom = 30;
                acreageTo   = 50;
                break;

            case 3:
                acreageFrom = 50;
                acreageTo   = 80;
                break;

            case 4:
                acreageFrom = 80;
                acreageTo   = 100;
                break;

            case 5:
                acreageFrom = 100;
                acreageTo   = 150;
                break;

            case 6:
                acreageFrom = 150;
                acreageTo   = 200;
                break;

            case 7:
                acreageFrom = 200;
                break;

            default:
                break;
            }
            #endregion calc acreage
            string pageQuery = Request.QueryString["page"];
            int    page      = 1;
            if (!string.IsNullOrEmpty(pageQuery))
            {
                page = Convert.ToInt32(pageQuery);
            }
            WebService.AnperoService sv = new WebService.AnperoService();
            WebService.SearchResult  rs = sv.SearchProductByLocation(StoreID, TokenKey, scat, parentCat, pricefrom, friceTo, page, 12, province, district, "", acreageFrom, acreageTo);
            ViewData["productList"] = rs;
            ViewBag.page            = Anpero.Paging.setUpPagedV2(page, 14, rs.ResultCount, 10, "?page=");
            if (rs != null && rs.Item.Length > 0)
            {
                ViewBag.Title = rs.Item[0].CatName;
            }

            SetupCommonProduct();

            return(View("Category"));
        }