public ActionResult Create(ProductCategory productCategory) { if (!ModelState.IsValid) { return(View(productCategory)); } else { context.Insert(productCategory); context.Commit(); return(RedirectToAction("Index")); } }
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")); } }
private static void AddEmployees(IRespository <Employee> employeeRespository) { employeeRespository.Add(new Employee { Name = "keep" }); employeeRespository.Add(new Employee { Name = "wan" }); employeeRespository.Commit(); }
public void AddToBasket(HttpContextBase httpContext, string productID) { Basket basket = GetBasket(httpContext, true); BasketItem item = basket.BasketItemCollection.FirstOrDefault(a => a.ProductID == productID); if (item == null) { item = new BasketItem() { BasketID = basket.Id, ProductID = productID, Quanity = 1 }; basket.BasketItemCollection.Add(item); } else { item.Quanity = item.Quanity + 1; } basketContext.Commit(); }