示例#1
0
        //
        // GET: /Product/Create/5
        public ActionResult Create(int id)
        {
            ProductCreateModel productCreateModel = new ProductCreateModel()
            {

                StoreID = id
            };

            return View(productCreateModel);
        }
示例#2
0
        //
        // 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);
        }
示例#3
0
        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();
            }
        }
示例#4
0
        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);
            }
        }