Exemplo n.º 1
0
        public override bool Init(Client client)
        {
            int productColorID;

            if (int.TryParse(BaseFuncs.GetAdditionalURLArray(client.URL, this.URL)[0], out productColorID))
            {
                ProductColor productColor = productColorService.GetByID(productColorID);
                if (productColor != null)
                {
                    Hashtable data = new Hashtable();

                    if (client.PostParam("EditProductColor") != null && client.PostParam("name") != null)
                    {
                        if (client.PostParam("RGB") != null)
                        {
                            productColorService.EditProductColor(client.PostParam("RGB"), client.PostParam("name"), productColorID);
                            client.Redirect("/product.color/#pr_" + productColor.ID);
                            Logger.ConsoleLog("Edited product color: " + productColor.RGB + " (ID: " + productColor.ID + ")", ConsoleColor.Yellow);

                            return(false);
                        }
                    }
                    data.Add("ProductColor", productColor);
                    client.HttpSend(TemplateActivator.Activate(this, client, data));
                    return(true);
                }
            }

            BaseFuncs.Show404(client);
            return(false);
        }
Exemplo n.º 2
0
        public List <ProductColor> GetProductColors(Product product)
        {
            List <ProductColor> productColors = new List <ProductColor>();

            foreach (string colorID in product.Colors.Split(','))
            {
                productColors.Add(productColorService.GetByID(int.Parse(colorID)));
            }
            return(productColors);
        }
Exemplo n.º 3
0
        public bool AddProduct(int productID, int productNum, string cookie, int productColorId = 0)
        {
            if (productService.GetByID(productID) != null && productNum > 0)
            {
                if (productColorId != 0)
                {
                    if (productColorService.GetByID(productColorId) == null)
                    {
                        productColorId = 0;
                    }
                }

                Cart cart = this.GetByCookieAndProductID(cookie, productID, productColorId);

                if (cart == null)
                {
                    cart              = new Cart();
                    cart.UniqueCode   = cookie;
                    cart.ProductID    = productID;
                    cart.ProductNum   = this.NumberForAddProduct(cart.ProductNum, productNum);
                    cart.ProductColor = productColorId;
                    DBConnector.manager.InsertQuery(cart);
                }
                else
                {
                    DBConnector.manager.FastUpdate <Cart>(data => {
                        Cart c = data as Cart;

                        if (c.ProductID == productID && c.UniqueCode == cookie && c.ProductColor == productColorId)
                        {
                            c.ProductNum = this.NumberForAddProduct(c.ProductNum, productNum);
                        }

                        return(null);
                    }, true);
                }

                return(true);
            }

            return(false);
        }