예제 #1
0
 public void State()
 {
     if (CheckAjax())
     {
         if (CheckRight())
         {
             if (IsPost)
             {
                 M.Product value = DbTable.Load <M.Product>(Request.Form);
                 if (value.State == M.ProductState.Sale)
                 {
                     value.SaleTime = DateTime.Now;
                 }
                 SetResult(value.Update(DataSource, ColumnMode.Include, "State", "SaleTime"), () =>
                 {
                     WritePostLog("MOD");
                 });
             }
             else
             {
                 NotFound();
             }
         }
     }
 }
예제 #2
0
 public virtual void Add()
 {
     try
     {
         M.Product product = M.Product.GetSaleProduct(DataSource, long.Parse(Request.Form["Id"]));
         if (product == null)
         {
             SetResult((int)-1023);
         }
         M.ProductCart cart = new M.ProductCart(DataSource, User.Identity.Id, product, int.Parse(Request.Form["Count"]));
         if (cart.Count <= product.Inventory)
         {
             M.ProductCart productcart = M.ProductCart.GetProductByUser(DataSource, User.Identity.Id, long.Parse(Request.Form["Id"]));
             if (productcart == null || productcart.Id <= 0)
             {
                 SetResult(cart.Add(DataSource));
             }
             else
             {
                 productcart.Count += int.Parse(Request.Form["Count"]);
                 SetResult(productcart.Update(DataSource));
             }
         }
         else
         {
             SetResult((int)-1027);
         }
     }
     catch (Exception ex)
     {
         SetResult(false, ex.ToString());
     }
 }
예제 #3
0
        public void Info(long id)
        {
            M.Product product = M.Product.GetSaleProduct(DataSource, id);
            if (product != null)
            {
                long parent = product.ParentId > 0 ? product.ParentId : product.Id;

                this["Product"]           = product;
                this["ParentId"]          = parent;
                this["Supplier"]          = M.Supplier.GetById(DataSource, product.SupplierId);
                this["Series"]            = M.ProductSerie.GetAll(DataSource, parent);
                this["Mapping"]           = M.ProductMapping.GetAllByProduct(DataSource, product.Id);
                this["Mappings"]          = M.ProductMapping.GetAllByAllProduct(DataSource, parent);
                this["Attributes"]        = M.ProductAttribute.GetAllValuesByProduct(DataSource, product.Id);
                this["CategoryList"]      = M.ProductCategory.GetAllParentsById(DataSource, product.CategoryId);
                this["RecommendList"]     = M.Product.GetTopRecommendByCategory(DataSource, 5, product.CategoryId);
                this["StoreInfo"]         = M.StoreInfo.GetStoreInfoByUserId(DataSource, product.SupplierId);
                this["ProductCount"]      = M.Product.GetProductCountBySupplierId(DataSource, product.SupplierId);
                this["StoreCategoryList"] = M.StoreCategory.GetStoreCategoryListByUserId(DataSource, product.SupplierId);
                this["categoryId"]        = 0;
                Render("product.html");
            }
            else
            {
                NotFound();
            }
        }
예제 #4
0
 public void DState()
 {
     if (CheckAjax())
     {
         if (CheckRight())
         {
             if (IsPost)
             {
                 M.Product value = DbTable.Load <M.Product>(Request.Form);
                 SetResult(value.Update(DataSource, ColumnMode.Include, "DiscountState"), () =>
                 {
                     WritePostLog("MOD");
                 });
             }
             else
             {
                 NotFound();
             }
         }
     }
 }
예제 #5
0
 //public void Add()
 //{
 //    if (CheckAjax())
 //    {
 //        if (CheckRight())
 //        {
 //            if (IsPost)
 //            {
 //                SetResult(M.Product.Insert(DataSource,
 //                    Request.Form["Title"],
 //                    Request.Form["Image"],
 //                    Request.Form["Content"],
 //                    int.Parse(Request.Form["Category"]),
 //                    DateTime.Parse(Request.Form["CreationDate"]),
 //                    Request.Form["Keywords"],
 //                    Request.Form["Description"],
 //                    "on".Equals(Request.Form["Visibility"]),
 //                    "on".Equals(Request.Form["Top"]),
 //                    int.Parse(Request.Form["Style"]),
 //                    Request.Form["Color"],
 //                    Request.Form["Author"],
 //                    Request.Form["Referer"]), () =>
 //                    {
 //                        WritePostLog("ADD");
 //                    });
 //            }
 //            else
 //            {
 //                NotFound();
 //            }
 //        }
 //    }
 //}
 public void Update()
 {
     if (CheckAjax())
     {
         if (CheckRight())
         {
             if (IsPost)
             {
                 M.Product value = DbTable.Load <M.Product>(Request.Form);
                 SetResult(value.Update(DataSource, ColumnMode.Include, "CategoryId", "Recommend", "CategoryBest", "SortNum"), () =>
                 {
                     WritePostLog("MOD");
                 });
             }
             else
             {
                 NotFound();
             }
         }
     }
 }
예제 #6
0
        public void View(long id)
        {
            M.Product product = M.Product.GetViewProduct(DataSource, id, User.Identity.Id);
            if (product != null)
            {
                long parent = product.ParentId > 0 ? product.ParentId : product.Id;

                this["Product"]       = product;
                this["ParentId"]      = parent;
                this["Supplier"]      = M.Supplier.GetById(DataSource, product.SupplierId);
                this["Series"]        = M.ProductSerie.GetAll(DataSource, parent);
                this["Mapping"]       = M.ProductMapping.GetAllByProduct(DataSource, product.Id);
                this["Mappings"]      = M.ProductMapping.GetAllByAllProductEx(DataSource, parent);
                this["Attributes"]    = M.ProductAttribute.GetAllValuesByProduct(DataSource, product.Id);
                this["CategoryList"]  = M.ProductCategory.GetAllParentsById(DataSource, product.CategoryId);
                this["RecommendList"] = M.Product.GetTopRecommendByCategory(DataSource, 5, product.CategoryId);
                Render("product.html");
            }
            else
            {
                NotFound();
            }
        }