Esempio n. 1
0
        public ActionResult Edit(ProductModel model, int id)
        {
            if (ModelState.IsValid)
            {
                var product = jlService.GetProduct(id);
                product.Alias             = model.Alias;
                product.Name              = model.Name;
                product.BriefIntroduction = model.BriefIntro;
                product.Description       = model.Description;
                product.MarketPrice       = model.MarketPrice ?? 0;
                product.RetailPrice       = model.RetailPrice ?? 0;
                product.SortIndex         = model.SortIndex ?? product.SortIndex;
                product.AddTime           = model.AddTime;
                // picture
                if (Request.Files != null &&
                    Request.Files.Count > 0 &&
                    Request.Files[0].ContentLength > 0)
                {
                    var imgLink = FileHelper.SaveProductImage(Request.Files[0]);
                    product.Picture = imgLink;
                }

                jlService.UpdateProduct(product);

                ResultObject rutObj = ResultObject.Succeed();
                ViewData.Add("ResultObject", rutObj);
            }

            new ViewDataHelper(jlService).InitializeCategories(ViewData, 0, "categoryid");
            return(View(model));
        }