public void Delete(string Id) { ProductCatergory productCategoryToDelete = productCategories.Find(p => p.Id == Id); if (productCategoryToDelete != null) { productCategories.Remove(productCategoryToDelete); } else { throw new Exception("Product Category Not FOund"); } }
public ActionResult Delete(string Id) { ProductCatergory productCategoryToDelete = Context.find(Id); if (productCategoryToDelete == null) { return(HttpNotFound()); } else { return(View(productCategoryToDelete)); } }
public ActionResult Edit(string Id) { ProductCatergory productCatergory = Context.find(Id); if (productCatergory == null) { return(HttpNotFound()); } else { return(View(productCatergory)); } }
public ProductCatergory find(string Id) { ProductCatergory productCatergory = productCategories.Find(p => p.Id == Id); if (productCategories != null) { return(productCatergory); } else { throw new Exception("Product Category Not FOund"); } }
public void Update(ProductCatergory productCategory) { ProductCatergory productCategoryToUpdate = productCategories.Find(p => p.Id == productCategory.Id); if (productCategoryToUpdate != null) { productCategoryToUpdate = productCategory; } else { throw new Exception("Product category Not Found"); } }
public ActionResult Create(ProductCatergory productCatergory) { if (!ModelState.IsValid) { return(View(productCatergory)); } else { Context.Insert(productCatergory); Context.Commit(); return(RedirectToAction("Index")); } }
public ActionResult ConfirmDelete(string Id) { ProductCatergory productCategoryToDelete = Context.find(Id); if (productCategoryToDelete == null) { return(HttpNotFound()); } else { Context.Delete(Id); Context.Commit(); return(RedirectToAction("Index")); } }
public ActionResult Edit(ProductCatergory product, string Id) { ProductCatergory productCategoryToEdit = Context.find(Id); if (productCategoryToEdit == null) { return(HttpNotFound()); } else { if (!ModelState.IsValid) { return(View(product)); } productCategoryToEdit.Category = product.Category; Context.Commit(); return(RedirectToAction("Index")); } }
public ActionResult Create() { ProductCatergory productCatergory = new ProductCatergory(); return(View(productCatergory)); }
public void Insert(ProductCatergory p) { productCategories.Add(p); }
public ActionResult Create(ProductViewModel model) { //try //{ string fileName = Path.GetFileNameWithoutExtension(model.FileContent.FileName); string extension = Path.GetExtension(model.FileContent.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; model.ImageUrl = "~/Photo/" + fileName; fileName = Path.Combine(Server.MapPath("~/Photo/"), fileName); model.FileContent.SaveAs(fileName); //Product table Product prdct = new Product(); prdct.productDescription = model.productDescription; prdct.productName = model.productName; prdct.productQuantity = model.productQuantity; prdct.promotionPrice = model.promotionPrice; prdct.expiryDate = model.expiryDate; prdct.ImageUrl = model.ImageUrl; for (int i = 0; i < Request.Files.Count; i++) { List <ProductGallery> galleryImages = new List <ProductGallery>(); var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var ImageName = Path.GetFileName(file.FileName); var FinalName = DateTime.Now.ToString("yymmssfff") + ImageName; ProductGallery fileDetail = new ProductGallery() { GalleryImageUrl = "~/Gallery/" + FinalName }; galleryImages.Add(fileDetail); var path = Path.Combine(Server.MapPath("~/Gallery/"), FinalName); file.SaveAs(Server.MapPath("~/Gallery/" + FinalName)); } prdct.prodcutImages = galleryImages; context.Products.Add(prdct); context.SaveChanges(); int prdctid = prdct.productId; //ProductCatergory table ProductCatergory crtgry = new ProductCatergory(); crtgry.prodcutId = prdctid; crtgry.CatergoryName = model.CatergoryName; context.ProductCatergorys.Add(crtgry); context.SaveChanges(); } //} //catch (Exception ex) //{ // ex.Message.ToString(); //} return(View()); }