// // GET: /Product/Create/5 public ActionResult Create(int id) { ProductCreateModel productCreateModel = new ProductCreateModel() { StoreID = id }; return View(productCreateModel); }
// // GET: /Product/Create/5 public ActionResult Create(int id) { ProductCreateModel productCreateModel = new ProductCreateModel() { Product = new Product(), ProductTemplates = WebTemplateRepository.GetAll().ToList(), StoreID = id }; return View(productCreateModel); }
public ActionResult Create(ProductCreateModel model) { try { var name = model.Product.Name; var htmlBanner = Server.HtmlEncode(model.Product.HtmlBanner); Store store = StoreRepository.Get(s => s.Id.Equals(model.StoreID)).SingleOrDefault(); store.AddProduct( new Product() { Name = name, HtmlBanner = htmlBanner }); StoreRepository.SaveOrUpdate(store); WebTemplateRepository.SaveOrUpdate(new WebTemplate() { Name = name + "ProductWebTemplate", Html = htmlBanner }); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Create(ProductCreateModel model) { try { Store store = StoreRepository.Get(s => s.Id.Equals(model.StoreID)).SingleOrDefault(); var htmlBanner = string.Format(_productTemplate, model.ImagePath, model.Name, model.Price); store.AddProduct(new Product() { Name = model.Name, Price = model.Price, HtmlBanner = Server.HtmlEncode(htmlBanner) }); StoreRepository.SaveOrUpdate(store); StoreRepository.SaveOrUpdate(store); return RedirectToAction("Index","Store"); } catch { return View(model); } }