示例#1
0
        public async Task <IActionResult> EditProduct(ViewModels.PM.Product.EditProductViewModel editProductViewModel)
        {
            string          ImagePath       = null;;
            ImageErrorModel imageErrorModel = new ImageErrorModel();

            if (editProductViewModel.DefaultImage == null)
            {
                ImagePath = editProductViewModel.OldImage;
            }
            else
            {
                ImagePath = UploadImage(editProductViewModel.DefaultImage, ref imageErrorModel);
            }
            if (ModelState.IsValid)
            {
                Product objProduct = await this.ProductBLL.Find(editProductViewModel.ID);

                objProduct.ID             = editProductViewModel.ID;
                objProduct.Specification  = editProductViewModel.Specification;
                objProduct.DefaultImage   = ImagePath;
                objProduct.Price          = editProductViewModel.DefauftPrice;
                objProduct.isOnlineOnly   = editProductViewModel.isOnlineOnly;
                objProduct.StockMin       = editProductViewModel.StockMin;
                objProduct.Details        = editProductViewModel.Details;
                objProduct.IsAllowComment = editProductViewModel.IsAllowComment;
                objProduct.CreatedTime    = editProductViewModel.CreateTime;
                objProduct.BrandID        = editProductViewModel.Brand;
                objProduct.CategoryID     = editProductViewModel.Category;
                objProduct.SubGroupID     = editProductViewModel.SubGroup;
                await ProductBLL.Update(objProduct);

                return(RedirectToAction("Index"));
            }
            return(View(editProductViewModel));
        }
示例#2
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        Product product = new Product();

        product.ProductName = txtProductName.Text;
        product.NormalPrice = decimal.Parse(txtNormalPrice.Text);
        product.MemberPrice = decimal.Parse(txtMemberPrice.Text);

        if (string.IsNullOrEmpty(_productId))
        {
            _productBLL.Insert(product);
        }
        else
        {
            product.ID = int.Parse(_productId);
            _productBLL.Update(product);
        }
        Response.Redirect("ProductList.aspx", true);
    }
示例#3
0
    private void Save()
    {
        string productId = Request.QueryString["productId"];

        Model.Product product = new Model.Product();
        product.ProductName = Request.Form["ProductName"];
        product.NormalPrice = decimal.Parse(Request.Form["NormalPrice"]);
        product.MemberPrice = decimal.Parse(Request.Form["MemberPrice"]);

        if (string.IsNullOrEmpty(productId))
        {
            productBLL.Insert(product);
        }
        else
        {
            product.ID = int.Parse(productId);
            productBLL.Update(product);
        }
        Response.Write("{success: true}");
        Response.End();
    }