public ActionResult Edit(Product product, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                RepositoryProduct.UpdateProduct(product, file);

                return(RedirectToAction("Index"));
            }
            return(View(product));
        }
예제 #2
0
        public async Task <string> UpdateProduct(models.Product product, int sku)
        {
            var producExisting = await GetProduct(sku);

            if (producExisting == null)
            {
                return("Não existe produto com o sku informado!");
            }

            return(await _repositoryProduct.UpdateProduct(sku, product));
        }
예제 #3
0
        protected void updateproduct_Click(object sender, EventArgs e)
        {
            Int32 prodtypeid = 0;
            Int32 price      = 0;
            Int32 stock      = 0;
            Int32 ID         = 0;

            Int32.TryParse(producttypeid.Text.ToString(), out ID);
            bool cek = RepositoryProductType.CekID(ID);

            if (cek)
            {
                String name = productname.Text.ToString();
                if (Int32.TryParse(producttypeid.Text.ToString(), out prodtypeid) &&
                    Int32.TryParse(productstock.Text.ToString(), out stock) &&
                    Int32.TryParse(productprice.Text.ToString(), out price) && name != "")
                {
                    if (validation(price, stock))
                    {
                        Int32 myid = Int32.Parse(Request.QueryString["id"]);
                        RepositoryProduct.UpdateProduct(myid, prodtypeid, name, price, stock);
                        Response.Write("<script>alert('Update product successfully.')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('Stock must be 1 or more and price must be above 1000 and multiply of 1000.')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Data can not be null and non numeric value.')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('Product type id does not exists.')</script>");
            }
        }