示例#1
0
 public ActionResult Create(ProductCategory productCategory)
 {
     if (!ModelState.IsValid)
     {
         return(View(productCategory));
     }
     else
     {
         context.Insert(productCategory);
         context.commit();
     }
     return(RedirectToAction("Index"));
 }
示例#2
0
        private Basket CreateNewBasket(HttpContextBase httpContext)
        {
            Basket basket = new Basket();

            basketContext.Insert(basket);
            basketContext.commit();

            HttpCookie cookie = new HttpCookie(BasketSessionName);

            cookie.Value   = basket.Id;
            cookie.Expires = DateTime.Now.AddDays(1);
            httpContext.Response.Cookies.Add(cookie);

            return(basket);
        }
 public ActionResult Create(Product product, HttpPostedFileBase file)
 {
     if (!ModelState.IsValid)
     {
         return(View(product));
     }
     else
     {
         if (file != null)
         {
             product.Image = product.Id + Path.GetExtension(file.FileName);
             file.SaveAs(Server.MapPath("//Content//Productimages//") + product.Image);
         }
         context.Insert(product);
         context.commit();
     }
     return(RedirectToAction("Index"));
 }