Esempio n. 1
0
        public IActionResult newbid(int productID, int bidding)
        {
            int  curUsrID = (int)HttpContext.Session.GetInt32("logged_id");
            User curUser  = _context.users.SingleOrDefault(u => u.idUsers == curUsrID);
            Prod curProd  = _context.prods.SingleOrDefault(p => p.ProdId == productID);

            System.Console.WriteLine(bidding);
            System.Console.WriteLine(curUser.Wallet);
            System.Console.WriteLine(curProd.StartingBid);
            System.Console.WriteLine("##################################################");
            if (curUser.Wallet < bidding || curProd.StartingBid >= bidding)
            {
                return(RedirectToAction("Logout"));
            }
            if (curProd.BidderId != 0)
            {
                User cheapskate = _context.users.SingleOrDefault(u => u.idUsers == curProd.BidderId);
                cheapskate.Wallet += curProd.StartingBid;
            }
            curUser.Wallet     -= bidding;
            curProd.BidderId    = curUsrID;
            curProd.BidderName  = curUser.FirstName;
            curProd.StartingBid = bidding;
            _context.SaveChanges();
            return(RedirectToAction("Success"));
        }
        private object[] InvokeMethod(MethodInfo mi, object[] args, object type)
        {
            object ret;

            try
            {
                Prod.ActivateWindow(_parentWindowHandle);
                ret = mi.Invoke(type, args);
            }
            catch (TargetInvocationException err)
            {
                MessageBox.Show(@"An error occurred while executing this method from within ProdSpy: " + err.InnerException.Message, @"Invocation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                object[] error = new object[1];
                error[0] = "ERR";
                return(error);
            }
            catch (ProdOperationException err)
            {
                MessageBox.Show(err.Message);
                object[] error = new object[1];
                error[0] = "ERR";
                return(error);
            }

            /* handle displays of return values */
            if (ret != null)
            {
                MessageBox.Show(ret.ToString(), mi.Name);
            }

            return(args);
        }
Esempio n. 3
0
        private string displayCartTable(List <userCart> cart)
        {
            string display = "";

            foreach (userCart c in cart)
            {
                Prod   pod   = client.GetProd(Convert.ToInt32(c.Prod_ID));
                double total = 0;
                total    += c.Quantity * pod.Price;
                subtotal += total;
                nProds++;

                display += "<tr class='text-center' id='" + c.Prod_ID + "row'>";
                display += "<td class='product-remove'><a type='button' onclick='remove(" + c.Prod_ID + "," + c.User_ID + ")'><span class='ion-ios-close'></span></a></td>";
                display += "<td class='image-prod'><div class='img' style='background-image:url(" + pod.Image + ")'></div></td>";
                display += "<td class='product-name'>";
                display += "<h3>" + pod.prodName + "</h3>";
                display += "<p>" + pod.description + "</p>";
                display += "</td>";
                display += "<td  class='price'><input id='" + c.Prod_ID + "price' value='" + Math.Round(pod.Price, 2) + "' " +
                           "style='display:none;'>$ " + Math.Round(pod.Price, 2) + "</td>";
                display += "<td class='quantity'>";
                display += "<div class='input-group mb-3'>";
                display += "<p class='text-center'><a onclick='decreasingQ(" + c.Prod_ID + "," + c.User_ID + ")' class='btn btn-primary py-3 px-4'> - </a></p>";
                display += "<input type='text' id='" + c.Prod_ID + "' readonly='readonly'  name='quantity' class='quantity form-control input-number' value='" + c.Quantity + "' min='1' max='100'>" +
                           "<p class='text-center'><a onclick='increasingQ(" + c.Prod_ID + "," + c.User_ID + ")' class='btn btn-primary py-3 px-4'> + </a></p></div></td>";
                display += "<td id='" + c.Prod_ID + "total' class='total'>$ " + Math.Round(total, 2) + "</td></tr>";
            }

            return(display);
        }
Esempio n. 4
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Prod Product = new Prod
            {
                prodName    = pName.Value,
                prodType    = pType.Value,
                sNumber     = sNumber.Value,
                Price       = Convert.ToDouble(pricr.Value),
                brand       = bName.Value,
                special     = Convert.ToInt32(special.Value),
                description = description.Value,
                Qty         = Convert.ToInt32(Qty.Value),
                Image       = image.Value,
                inStock     = 1
            };

            if (Product != null)
            {
                bool check = client.appendNewProduct(Product);

                if (check == true)
                {
                    int id = client.searchProd(sNumber.Value);
                    Response.Redirect("productInfo.aspx?ID=" + id);
                }
                else
                {
                }
            }
        }
Esempio n. 5
0
        public async Task <IHttpActionResult> PutProd(int id, Prod prod)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != prod.Id)
            {
                return(BadRequest());
            }

            db.Entry(prod).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProdExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 6
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            Prod p = new Prod
            {
                prodName    = name.Value,
                prodType    = pType.Value,
                sNumber     = sNumber.Value,
                Price       = Convert.ToDouble(prodPrice.Value),
                brand       = brand.Value,
                special     = Convert.ToInt32(productSpecial.Value),
                description = description.Value,
                Qty         = Convert.ToInt32(quantity.Value),
                Image       = image.Value
            };
            int  id   = Convert.ToInt32(Request.QueryString["ID"]);
            bool edit = client.modifyProd(p, Convert.ToInt32(id));

            if (edit == true)
            {
                Response.Write("<script>window.alert('Changes Made Successfully!')</script>");
                Response.Redirect("productInfo.aspx?ID=" + id);
            }
            else
            {
                messageDiv.Visible = true;
                message.Value      = "Something Went Wrong Please Again Later";
            }
        }
Esempio n. 7
0
        static object InflateEnum(string name, int[] loc)
        {
            List <string[]> names = new List <string[]>();
            int             rpos2 = loc[6];

            while (rpos2 < loc[7])
            {
                string   rname = AsciiZ(ref rpos2);
                string[] keys;
                if (!val_aliases.TryGetValue(Prod.C(name, rname), out keys))
                {
                    keys = new string[] { rname }
                }
                ;
                names.Add(keys);
            }
            int rpos0 = loc[2];
            int rpos1 = loc[4];

            int[] data = new int[(loc[5] - loc[4]) * 2];
            int   lix  = 0;

            for (int i = 0; i < data.Length / 2; i++)
            {
                lix            += (int)BER(ref rpos0);
                data[2 * i]     = lix;
                data[2 * i + 1] = bits[rpos1++];
                //if (Trace) Console.WriteLine("inflate: {0} = {1}", data[2*i], names[data[2*i+1]][0]);
            }

            return(new LimitedProperty(data, names.ToArray()));
        }
Esempio n. 8
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Price,ImagenName,Status")] Prod producto1)
        {
            if (id != producto1.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(producto1);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductoExists(producto1.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(producto1));
        }
Esempio n. 9
0
        // GET: Prods/Edit/5
        public ActionResult Edit(int?id)
        {
            Prod prod = db.Prods.Find(id);

            ViewBag.CATEGORY_FID = new SelectList(db.Categories, "CATEGORY_ID", "CATEGORY_NAME", prod.CATEGORY_FID);
            return(View(prod));
        }
Esempio n. 10
0
        public async Task ActionBegin(ActionEventArgs <Prod> args)
        {
            if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
            {
                HttpResponseMessage response;
                bool found = prods.Any(p => p.CG_PROD == args.Data.CG_PROD);
                Prod ur    = new Prod();

                if (!found)
                {
                    args.Data.CG_CIA  = 1;
                    args.Data.USUARIO = "User";
                    response          = await Http.PostAsJsonAsync("api/Prod", args.Data);

                    args.Data.CG_PROD = prods.Max(s => s.CG_PROD) + 1;
                }
                else
                {
                    response = await Http.PutAsJsonAsync($"api/Prod/{args.Data.CG_PROD}", args.Data);
                }

                if (response.StatusCode == System.Net.HttpStatusCode.Created)
                {
                }
            }

            if (args.RequestType == Syncfusion.Blazor.Grids.Action.Delete)
            {
                await EliminarProd(args);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Demonstrates creating a simple Prod using preconfigured loggers from a configuration file
        /// </summary>
        public static void LoadConfigFile()
        {
            try
            {
                /* Loading a set of loggers from a configuration file (located in the /bin directory */
                LoggingConfiguration lc = new LoggingConfiguration();
                /* Adding them to the controller */
                LogController.AddActiveLogger(lc.LoadFromConfiguration(@"loggers.ses"));

                /* start the application and wait until it exists */
                Process.Start("MasterWinformTest.exe");
                Prod.WinWaitExists(WIN_TITLE);

                /* Get the parent window and add loggers */
                ProdWindow window = new ProdWindow(WIN_TITLE);

                /* here's the control we want to Prod */
                ProdCheckBox chk1 = new ProdCheckBox(window, "checkBox1");

                /* We'll monkey with the slider control */
                ProdSlider slider = new ProdSlider(window, "trackBarTest");
                slider.SetValue(3);

                chk1.SetCheckState(ToggleState.On);
            }
            catch (ProdUI.Exceptions.ProdOperationException e)
            {
                /* Show any errors */
                Debug.WriteLine(">>>>>>>" + e.InnerException.Message + "<<<<<<<<");
            }
        }
Esempio n. 12
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,NombreProducto,Precio")] Prod prod)
        {
            if (id != prod.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prod);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProdExists(prod.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(prod));
        }
Esempio n. 13
0
        private void HandleData(int Port, byte[] Data)
        {
            if (Data.Length > 1)
            {
                PGN = Data[0] << 8 | Data[1];
                if (PGN == 32897)
                {
                    // AGIO
                    // AutoSteer AGIO PGN
                    switch (Data[3])
                    {
                    case 0xFE:
                        mf.AutoSteerPGN.ParseByteData(Data);
                        break;
                    }
                }
                else
                {
                    switch (PGN)
                    {
                    case 32618:
                        mf.SwitchBox.ParseByteData(Data);
                        break;

                    case 32613:
                        foreach (clsProduct Prod in mf.Products.Items)
                        {
                            Prod.UDPcommFromArduino(Data);
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 14
0
 static PWApp()
 {
     CONF = AssetUtils.GetConfig(CONF_NAME);
     if (CONF != null)
     {
         Prod.Checkin(CONF);
     }
 }
Esempio n. 15
0
 /// <summary>
 /// App data
 /// </summary>
 static PWApp()
 {
     conf = AssetUtils.GetConfig(CONF_NAME, true);
     if (conf != null)
     {
         Prod.Checkin(conf);
     }
 }
Esempio n. 16
0
        /*
         * internal bool blaklist(NonAddresseS2 nonAddresseS)
         * {
         *  //            this.TGs.emplacement.Contains(x => x.);
         *  return TGs.emplacement.Contains(new TG.Doubleint { rayon = nonAddresseS.Alle, trave = nonAddresseS.Trave });
         * }*/

        private Parameters()
        {
            this.prod   = new Prod();
            this.TGs    = new TG();
            this.ps     = new LisSecteur();
            this.emag   = new Emag();
            this.client = new ClientPar();
        }
Esempio n. 17
0
        public ActionResult DeleteConfirmed(int id)
        {
            Prod prod = db.Prods.Find(id);

            db.Prods.Remove(prod);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 18
0
 public ProductModel GetProduct(int Id)
 {
     using (var context = new Prod())
     {
         var query = context.Students
                     .where (s => s.StudentName == "Bill")
                     .FirstOrDefault <Student>();
     }
 }
Esempio n. 19
0
        private void ReceiveData(string sentence)
        {
            try
            {
                // look for ',' and '\r'. Return if not found
                int end = sentence.IndexOf(",", StringComparison.Ordinal);
                if (end == -1)
                {
                    return;
                }

                end = sentence.IndexOf("\r");
                if (end == -1)
                {
                    return;
                }

                sentence = sentence.Substring(0, end);
                string[] words = sentence.Split(',');

                if (words.Length > 1)
                {
                    if (byte.TryParse(words[0], out HiByte))
                    {
                        if (byte.TryParse(words[1], out LoByte))
                        {
                            int PGN = HiByte << 8 | LoByte;

                            switch (PGN)
                            {
                            case 32618:
                                if (mf.SwitchBox.ParseStringData(words))
                                {
                                    SerialActive = true;
                                }
                                break;

                            case 32613:
                                foreach (clsProduct Prod in mf.Products.Items)
                                {
                                    if (Prod.SerialFromAruduino(words))
                                    {
                                        SerialActive = true;
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                mf.Tls.WriteErrorLog("SerialComm/ReceiveData: " + ex.Message);
            }
        }
Esempio n. 20
0
        static void InflateAliases()
        {
            int[] loc = directory["!PropertyAlias"];
            aliases       = new Dictionary <string, string>();
            val_aliases   = new Dictionary <Prod <string, string>, string[]>();
            proxy_aliases = new Dictionary <string, string>();

            int rpos = loc[2];

            while (rpos < loc[3])
            {
                string main = AsciiZ(ref rpos);
                string alias;
                aliases[StringProperty.Loosen(main)] = main;
                while ((alias = AsciiZ(ref rpos)).Length != 0)
                {
                    aliases[StringProperty.Loosen(alias)] = main;
                    //if (Trace) Console.WriteLine("Alias {0} -> {1}", alias, main);
                }
            }
            aliases["SCRIPTEXTENSIONS"] = aliases["SCX"] = "scx";

            loc  = directory["!pva"];
            rpos = loc[2];
            List <string> aset = new List <string>();

            while (rpos < loc[3])
            {
                string tbl   = AsciiZ(ref rpos);
                string canon = AsciiZ(ref rpos);
                if (canon == "n/a")
                {
                    canon = AsciiZ(ref rpos);
                }
                string alias;
                aset.Add(canon);
                while ((alias = AsciiZ(ref rpos)).Length != 0)
                {
                    aset.Add(alias);
                }
                //if (Trace) Console.WriteLine("Alias {0},{1} -> {2}", tbl, canon, Kernel.JoinS(", ", aset));
                val_aliases[Prod.C(tbl, canon)] = aset.ToArray();

                if (tbl == "sc" || tbl == "gc" || tbl == "blk")
                {
                    foreach (string a in aset)
                    {
                        aliases[(tbl == "blk" ? "IN" : "") +
                                StringProperty.Loosen(a)] = tbl + "+" + canon;
                    }
                    proxy_aliases[tbl + "+" + canon] = tbl == "sc" ? "Script" : tbl;
                }
                aset.Clear();
            }
        }
Esempio n. 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            client.IncrementTracking("ProductInfo");
            int id = Convert.ToInt32(Request.QueryString["ID"]);

            string display = "";

            Prod cl = client.GetProd(id);

            display += "<div class='row'>";
            display += "<div class='col-lg-6 mb-5 ftco-animate'>";
            display += "<a href='productInfo.aspx?ID=" + cl.ID + "' class='image-popup'><img src='" + cl.Image + "' class='img-fluid' alt='Colorlib Template'></a>";
            display += "</div>";
            display += "<div class='col-lg-6 product-details pl-md-5 ftco-animate'>";
            display += "<h3>" + cl.prodName + "</h3>";
            display += "<h5>" + cl.brand + "</h5>";
            display += "<p>" + cl.description + "</p>";
            display += "<h4 class='price'><span>R " + Math.Round(cl.Price, 2) + "</span></h4>";
            display += "<div class='row mt-4'>";
            display += "<div class='col-md-6'>";
            display += "<div class='form-group d-flex'>";
            display += "<div class='select-wrap'>";
            display += "<div class='icon'><span class='ion-ios-arrow-down'></span></div>";
            display += "</div>";
            display += "</div>";
            display += "</div>";
            //display += "<div class='w-100'></div>";
            //display += "<div class='input-group col-md-6 d-flex mb-3'>";
            //display += "<span class='input-group-btn mr-2'>";
            //display += "<button type='button' class='quantity-left-minus btn'  data-type='minus' data-field=''>";
            //display += "<i class='ion-ios-remove'></i>";
            //display += "</button>";
            //display += "</span>";
            //display += "<input type='text' id='quantity' name='quantity' class='form-control input-number' value='1' min='1' max='100'>";
            //display += "<span class='input-group-btn ml-2'>";
            //display += "<button type='button' class='quantity-right-plus btn' data-type='plus' data-field=''>";
            //display += " <i class='ion-ios-add'></i>";
            //display += " </button>";
            //display += "</span>";

            if (Session["ID"] != null)
            {
                String strID = Session["ID"].ToString();
                //display += "<p class='bottom-area d-flex'>";
                display += "<button type='button' class='btn btn-primary py-3 px-5'  style='postion:center;' onclick='addCart(" + cl.ID + "," + strID + ")'>Add to cart</button>";
                display += "</p>";
                //display += "<p id='" + cl.ID + "Added'style='color:green; display:none;>Item Successfully added to cart!</p>";
                //display += "<p id='" + cl.ID + "NoAdd'style='color:red; display:none; postion:center;'>Item not added to cart!</p>";
            }

            display += "</div>";
            display += "</div>";
            display += "</div>";
            AboutProduct.InnerHtml = display;
        }
Esempio n. 22
0
        public async Task <IActionResult> Create([Bind("ID,Name,Price,ImagenName,Status")] Prod producto1)
        {
            if (ModelState.IsValid)
            {
                _context.Add(producto1);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(producto1));
        }
Esempio n. 23
0
        public async Task <IActionResult> Create([Bind("Id,NombreProducto,Precio")] Prod prod)
        {
            if (ModelState.IsValid)
            {
                _context.Add(prod);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(prod));
        }
Esempio n. 24
0
        public async Task <IHttpActionResult> GetProd(int id)
        {
            Prod prod = await db.Prods.FindAsync(id);

            if (prod == null)
            {
                return(NotFound());
            }

            return(Ok(prod));
        }
Esempio n. 25
0
 private void button5_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     CodProd.Clear();
     Prod.Clear();
     pre.Clear();
     cu.Clear();
     uti.Clear();
     cant.Clear();
     des.Clear();
     Cursor.Current = Cursors.Default;
 }
Esempio n. 26
0
 public static Activity ToContract(this Prod dataBaseActivity)
 {
     if (dataBaseActivity == null)
     {
         return(null);
     }
     return(new Activity
     {
         Id = dataBaseActivity.ProdNo,
         Description = dataBaseActivity.Descr,
     });
 }
Esempio n. 27
0
        public async Task <IHttpActionResult> PostProd(Prod prod)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Prods.Add(prod);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = prod.Id }, prod));
        }
        protected void btnPayment_Click(object sender, EventArgs e)
        {
            if (Terms.Checked)
            {
                Random rand  = new Random();
                int    order = rand.Next(100, 100001);

                /*while(client.OrderExists(order))
                 * {
                 *  order = rand.Next(100, 100001);
                 * }*/

                bDetails billing = new bDetails
                {
                    Name          = name.Value,
                    Surname       = surname.Value,
                    Email         = email.Value,
                    Province      = Province.Value,
                    House_Adress  = HouseNum.Value,
                    City          = TownCity.Value,
                    Street_Adress = street.Value,
                    ZIP           = zip.Value,
                    Phone         = phone.Value,
                    Order_ID      = order,
                    User_ID       = Convert.ToInt32(Session["ID"].ToString())
                };

                if (client.addDetails(billing) == 1)
                {
                    Prod   prod      = client.GetProd(getProdID());
                    double amountDue = Convert.ToDouble(Session["Total"].ToString());

                    Response.Write("<form action='https://www.sandbox.paypal.com/cgi-bin/webscr' method='post' name='buyCredits' id='buyCredit'>");
                    Response.Write("<input type='hidden' name='cmd' value='_xclick'>");
                    Response.Write("<input type='hidden' name='business' value='*****@*****.**'>");
                    Response.Write("<input type='hidden' name='currency_code' value='USD'>");
                    Response.Write("<input type='hidden' name='item_name' value='" + prod.prodName + "'>");
                    Response.Write("<input type='hidden' name='item_number' value='" + prod.ID + "'>");
                    Response.Write("<input type='hidden' name='amount' value='" + Convert.ToString(Math.Round(amountDue, 2)).Replace(",", ".") + "'>");
                    Response.Write("<input type='hidden' name='return' value='http://localhost:58955/Receipt.aspx?order=" + order + "'>");
                    Response.Write("</form>");

                    Response.Write("<script type='text/javascript'>");
                    Response.Write("document.getElementById('buyCredit').submit();");
                    Response.Write("</script>");
                }
            }
            else
            {
                System.Web.HttpContext.Current.Response.Write("<script>window.alert('Please Accept The Terms & Conditions')</script>");
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Used to run things after a package was imported.
        /// </summary>
        private static void OnPackageImport()
        {
            if (m_conf == null)
            {
                m_conf = AssetUtils.GetConfig(CONF_NAME);
            }
            Prod.Checkin(m_conf);

            // No need for these anymore
            AssetDatabase.importPackageCompleted -= OnImportPackageCompleted;
            AssetDatabase.importPackageCancelled -= OnImportPackageCancelled;
            AssetDatabase.importPackageFailed    -= OnImportPackageFailed;
        }
Esempio n. 30
0
        private string parseProdFromDeviceID(string deviceId)
        {
            string[] splitDeviceId = deviceId.Split('\\');
            string   Prod;

            //Разбиваем строку на несколько частей.
            //Каждая чаcть отделяется по символу &
            string[] splitProd = splitDeviceId[1].Split('&');

            Prod = splitProd[2].Replace("PROD_", "");;
            Prod = Prod.Replace("_", " ");
            return(Prod);
        }
Esempio n. 31
0
    // Method to add product to the cart.  If the product already exists, just update the quantity by one
    public void AddProduct(string id, string name, decimal price, int qty)
    {
        Prod result = products.Find(
            delegate(Prod tp)
            {
                return tp.ID == id;
            }
            );

        if (result != null)
        {
            UpdateQuantity(result.Quantity + 1, result.ID);
        }
        else
        {
            Prod tp = new Prod(id, name, price, qty);
            products.Add(tp);
        }
    }
        public IActionResult Mini(int id, Prod.Mini item)
        {
            var result = new Result();
            item.Id = id;
            item.UserId = 1;

            if (item.Skus != null && item.Skus.Any())
            {
                item.Price = item.Skus.Min(x => x.Price);
                item.Stock = item.Skus.Sum(x => x.Stock);
            }
            result.Status = DefaultStorage.ProdMiniUpdate(item);
            return Json(result);
        }
        public IActionResult Item(int id, int catgId, int spuId, Prod.Item item)
        {
            var userId = 1;
            var result = new Result<string>();
            if (id < 0 || id < 0)
            {
                result.Message = "参数错误";
                return Json(result);
            }
            var form = Request.Form;
            var time = DateTime.Now;
            var propPrefix = "prop.";
            var itemPrefix = "item.";

            if (item.Name.IsNullOrEmpty() || item.Name.Length > 30)
            {
                result.Data = "name";
                return Json(result);
            }
            if (!item.Title.IsNullOrEmpty() && item.Title.Length > 30)
            {
                result.Data = "title";
                return Json(result);
            }
            if (item.Stock < 1 || item.Stock > 99999999)
            {
                result.Data = "stock";
                return Json(result);
            }
            if (item.RetailPrice < 1 || item.RetailPrice > 99999999)
            {
                result.Data = "retailPrice";
                return Json(result);
            }
            if (item.Price < 1 || item.Price > 99999999)
            {
                result.Data = "price";
                return Json(result);
            }
            if (item.AppPrice < 1 || item.AppPrice > 99999999)
            {
                result.Data = "appPrice";
                return Json(result);
            }
            var summary = form[itemPrefix + "summary"].ToString();
            if (summary.IsNullOrEmpty() || (summary.Length < 5 || summary.Length > 200))
            {
                result.Data = "summary";
                return Json(result);
            }

            var subStock = form[itemPrefix + "subStock"].ToString().As<byte>(0);

            var isTiming = false;
            var onlineTime = time;
            var itemStatus = Prod.Status.Online;
            var onlineTimeField = form[itemPrefix + "online"];
            if (onlineTimeField == "0" || onlineTimeField == "1")
            {
                if (onlineTimeField == "1")
                {
                    itemStatus = Prod.Status.Offline;
                }
            }
            else if (!DateTime.TryParse(onlineTimeField, out onlineTime))
            {
                //var error = new { name = prefix + "onlineTime", message = "请选择日期及时间!" };
                //errors.Add(error);
                result.Data = "onlinetime";
                result.Message = "请选择日期及时间!";
                return Json(result);
            }
            else
            {
                isTiming = true;
            }

            var data = DefaultStorage.CatgGet(catgId);
            if (data == null || !data.Props.Any())
            {
                result.Message = "参数错误!";
                return Json(result);
            }

            var props = new List<Prod.Prop>();
            var propIdBuilder = new StringBuilder();
            var propStrBuilder = new StringBuilder();
            foreach (var p in data.Props)
            {
                if (p.IsEnumProp && p.Values != null)
                {
                    var val = form[propPrefix + p.Id].ToArray().Where(x => !string.IsNullOrEmpty(x)).ToArray();
                    var array = Array.ConvertAll(val, Convert.ToInt32);

                    foreach (var o in array)
                    {
                        foreach (var v in p.Values)
                        {
                            if (o > 0 && o == v.Id)
                            {
                                var prop = new Prod.Prop();
                                prop.PId = p.Id;
                                prop.VId = v.Id;
                                prop.PName = p.Name;
                                prop.VName = v.Name;
                                prop.Extra = string.Empty;
                                if (p.IsSaleProp)
                                {
                                    prop.Extra = "sale";
                                }
                                if (p.IsColorProp)
                                {
                                    prop.Extra += " color";
                                }
                                if (p.Id == 20000)
                                {
                                    item.BrandId = v.Id;
                                    item.BrandName = v.Name;
                                }
                                props.Add(prop);

                                if (!p.IsSaleProp)
                                {
                                    propIdBuilder.Append(p.Id + ":" + v.Id + ";");
                                    propStrBuilder.Append(p.Id + ":" + v.Id + ":" + p.Name + ":" + v.Name + ";");
                                }
                            }
                        }
                    }
                }
            }

            var skus = new List<Prod.Sku>();

            var saleProps = props.Where(x => x.Extra.Contains("sale")).ToList();

            var saleKeys = new List<string[]>();
            foreach (var g in saleProps.OrderBy(x => x.PId).GroupBy(g => g.PId))
            {
                var keys = g.Select(x => g.Key + ":" + x.VId).ToArray();
                saleKeys.Add(keys);
            }

            var skuKeys = GetAllSkuKeys(saleKeys);
            if (skuKeys != null && skuKeys.Any())
            {
                foreach (var skuKey in skuKeys)
                {
                    if (skuKey.IsNullOrEmpty()) continue;
                    var codeParam = "sku.code." + skuKey;
                    var stockParam = "sku.stock." + skuKey;
                    var priceParam = "sku.price." + skuKey;
                    var appPriceParam = "sku.appPrice." + skuKey;
                    var barcodeParam = "sku.barcode." + skuKey;

                    int stock;
                    decimal price, appPrice;

                    var codeVal = form[codeParam].ToString().Trim();
                    var stockVal = form[stockParam].ToString().Trim();
                    var priceVal = form[priceParam].ToString().Trim();
                    var appPriceVal = form[appPriceParam].ToString().Trim();
                    var barcodeVal = form[barcodeParam].ToString().Trim();

                    if (stockVal.IsNullOrEmpty() || !int.TryParse(stockVal, out stock) || priceVal.IsNullOrEmpty() || !decimal.TryParse(priceVal, out price) || appPriceVal.IsNullOrEmpty() || !decimal.TryParse(appPriceVal, out appPrice))
                    {
                        continue;
                    }

                    var nvs = skuKey.Split(';');
                    var propstr = string.Empty;
                    foreach (var nv in nvs)
                    {
                        var pid = nv.Split(':')[0].AsInt();
                        var vid = nv.Split(':')[1].AsInt();
                        var pname = saleProps.First(o => o.PId == pid).PName;
                        var vname = saleProps.First(o => o.VId == vid).VName;
                        propstr += string.Format("{0}:{1}:{2}:{3};", pid, vid, pname, vname);
                    }

                    var sku = new Prod.Sku();
                    sku.SpuId = spuId;
                    sku.UserId = userId;
                    sku.CatgId = catgId;
                    sku.CatgRId = 0;
                    sku.CatgMId = "";
                    sku.Code = codeVal;
                    sku.Barcode = barcodeVal;
                    sku.BrandId = item.BrandId;
                    sku.Stock = stock;
                    sku.Price = price;
                    sku.AppPrice = appPrice;
                    sku.PropId = skuKey;
                    sku.PropStr = propstr.TrimEnd(';');
                    sku.SaleCount = 0;
                    sku.Status = itemStatus;
                    sku.CreatedOn = time;
                    sku.ModifiedBy = "";
                    sku.ModifiedOn = time;

                    skus.Add(sku);
                }
            }

            var colorImgDic = new Dictionary<string, string>();
            var colorProps = props.Where(x => x.Extra.Contains("color")).ToList();
            foreach (var p in colorProps)
            {
                var key = p.PId + ":" + p.VId;
                var colorParam = "color.img." + key;
                var val = form[colorParam].ToString();

                if (!val.IsNullOrEmpty())
                {
                    colorImgDic.Add(key, val);
                }
            }

            var itemImgs = form["item.img"].ToArray().Where(x => !string.IsNullOrEmpty(x)).Take(5);
            var picture = itemImgs.FirstOrDefault();
            var itemImgStr = string.Join(";", itemImgs);

            item.SpuId = spuId;
            item.UserId = userId;
            item.CatgId = catgId;
            item.CatgRId = 0;
            item.CatgMId = "";
            item.Code = item.Code;
            item.Name = item.Name.StripHtml();
            item.Title = item.Title.StripHtml();
            item.Barcode = item.Barcode;
            item.Keyword = "";
            item.PropId = propIdBuilder.ToString().TrimEnd(';');
            item.PropStr = propStrBuilder.ToString().TrimEnd(';');
            item.PropAlias = string.Empty;
            item.InputId = "";
            item.InputStr = "";
            item.Summary = summary;
            item.Picture = picture;
            item.ItemImgStr = itemImgStr;
            item.PropImgStr = JsonConvert.SerializeObject(colorImgDic);
            item.Width = 0;
            item.Depth = 0;
            item.Height = 0;
            item.Weight = 0;
            item.Location = "";
            item.IsBonded = false;
            item.IsOversea = false;
            item.IsTiming = isTiming;
            item.IsVirtual = false;
            item.IsAutoFill = false;
            item.SupportCod = false;
            item.FreePostage = false;
            item.PostageTplId = 1;
            item.SubStock = subStock;
            item.Showcase = 1;
            item.OnlineOn = time;
            item.OfflineOn = time.AddDays(15);
            item.RewardRate = 0.5m;
            item.HasInvoice = false;
            item.HasWarranty = false;
            item.HasGuarantee = false;
            item.SaleCount = 0;
            item.CollectCount = 0;
            item.ConsultCount = 0;
            item.CommentCount = 0;
            item.Status = itemStatus;
            item.CreatedOn = time;
            item.ModifiedBy = "";
            item.ModifiedOn = time;

            item.Skus = skus;

            item.Desc.CreatedOn = time;
            item.Desc.ModifiedBy = "";
            item.Desc.ModifiedOn = time;

            if (id > 0)
            {
                item.Id = id;
                var propIds = item.Skus.Select(x => x.PropId);

                var oldSkus = DefaultStorage.ProdSkuList(id);

                var oldSkuPropIds = oldSkus.Select(x => x.PropId);

                var dic = oldSkus.ToDictionary(x => x.PropId, x => x.Id);
                foreach (var sku in item.Skus)
                {
                    if (dic.ContainsKey(sku.PropId))
                    {
                        sku.Id = dic[sku.PropId];//更新
                    }
                    else
                    {
                        sku.Id = 0;//新增
                    }
                }

                var deletedPropIds = oldSkuPropIds.Except(propIds);//删除的

                var deletedIds = oldSkus.Where(x => deletedPropIds.Contains(x.PropId)).Select(x => x.Id);

                result.Status = DefaultStorage.ProdItemUpdate(item, deletedIds.ToArray());
                return Json(result);
            }

            var newId = DefaultStorage.ProdItemCreate(item);
            result.Data = newId.ToString();
            result.Status = newId > 0;

            return Json(result);
        }