Example #1
0
        public ActionResult Update(ProductModel productmodel)
        {
            //productmodel.ID = Request;
            CommonResponse Response = WebApiOperation.SendPost <ProductModel, CommonResponse>(Constants.PRODUCT_API_BASE_URI, Constants.PRODUCT_API_UPDATE, productmodel);

            B_Commerce.SMVC.Areas.Admin.Models.GetProductModelResponse product = WebApiOperation.SendPost <int, B_Commerce.SMVC.Areas.Admin.Models.GetProductModelResponse>(Constants.PRODUCT_API_BASE_URI, Constants.PRODUCT_API_GETPRODUCTBYID, productmodel.ID);

            if (Response.Code != 0)
            {
                ViewBag.error = Response.Message;
                return(View("~/Areas/Admin/Views/Product/Add.cshtml", product.GetProductModel));
            }

            ViewBag.error = MyResource.Resource.General_Success;
            return(View("~/Areas/Admin/Views/Product/Add.cshtml", product.GetProductModel));
        }
Example #2
0
        public ActionResult Add(ProductModel productModel)
        {
            //productservisten categorylistesini al
            if (!ModelState.IsValid)
            {
                return(View());
            }

            if (Request.Files.Count > 0)
            {
                //resim var
                string path = Server.MapPath("/");

                if (!Directory.Exists(path + "/ProductImage"))
                {
                    Directory.CreateDirectory(path + "/ProductImage");
                }

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    string imagePath = path + "/ProductImage/" + Request.Files[i].FileName;
                    Request.Files[i].SaveAs(imagePath);
                    productModel.ProductImages.Add("/ProductImage/" + Request.Files[i].FileName);
                }
            }

            CommonResponse categoryChangeResponse = WebApiOperation.SendPost <ProductModel, CommonResponse>(Constants.PRODUCT_API_BASE_URI, Constants.PRODUCT_API_ADD, productModel);

            if (categoryChangeResponse.Code != 0)
            {
                ViewBag.error = categoryChangeResponse.Message;
                return(View());
            }
            ViewBag.error = MyResource.Resource.General_Success;
            return(View());
        }