public ActionResult New(ProductModel model) { if (ModelState.IsValid) { Product product = new Product(); product.Name = model.Name; product.Alias = model.Alias; product.BriefIntroduction = model.BriefIntro; product.Description = model.Description; product.MarketPrice = model.MarketPrice ?? product.MarketPrice; product.RetailPrice = model.RetailPrice ?? product.RetailPrice; if (Request.Files != null && Request.Files.Count > 0) { var imgLink = FileHelper.SaveProductImage(Request.Files[0]); product.Picture = imgLink; } var productId = jlService.AddProduct(product); if (model.CategoryId > 0) { jlService.ProductToCategory(productId, new int[] { model.CategoryId.Value }); } ResultObject rutObj = ResultObject.Succeed(); ViewData.Add("ResultObject", rutObj); } new ViewDataHelper(jlService).InitializeCategories(ViewData, 0, "categoryid"); return(View()); }