public ActionResult Delete(int id) { using (WaitoEntities entities = new WaitoEntities()) { WaitoProduct product_db = entities.WaitoProducts.Where(p => p.ProductID == id).FirstOrDefault(); entities.WaitoProducts.Remove(product_db); entities.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult Delete(int id) { using (WaitoEntities entities = new WaitoEntities()) { WaitoRecipe recipe_db = entities.WaitoRecipes.Where(r => r.RecipeID == id).FirstOrDefault(); entities.WaitoRecipes.Remove(recipe_db); entities.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult Delete(int id) { using (WaitoEntities entities = new WaitoEntities()) { WaitoDistributor distributor_db = entities.WaitoDistributors.Where(d => d.DistributorId == id).FirstOrDefault(); entities.WaitoDistributors.Remove(distributor_db); entities.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult Edit(int id) { WaitoPage pages_db = new WaitoEntities().WaitoPages.Where( p => p.PageId == id).FirstOrDefault(); Page page = new Page() { PageId = pages_db.PageId, PageName = pages_db.PageName, PageContent = pages_db.PageContent }; return View(page); }
public ActionResult Edit(int id) { WaitoDistributor distributor_db = new WaitoEntities().WaitoDistributors.Where( d => d.DistributorId == id).FirstOrDefault(); Distributor distributor = new Distributor() { DistributorId = distributor_db.DistributorId, Title = distributor_db.Title, Description = distributor_db.Description, Address = distributor_db.Address, Phone = distributor_db.Phone }; return View(distributor); }
public ActionResult Details(int id) { WaitoRecipe recipe_db = new WaitoEntities().WaitoRecipes.Where(r => r.RecipeID == id).FirstOrDefault(); Recipe recipe = new Recipe() { RecipeId = recipe_db.RecipeID, Title = recipe_db.Title, Serves = recipe_db.Serves, Ingredient = recipe_db.Ingredients, Description = recipe_db.Description, MediumImage = recipe_db.MediumImage, LargeImage = recipe_db.LargeImage }; return View(recipe); }
public ActionResult Create(Product product, HttpPostedFileBase MediumImage, HttpPostedFileBase LargeImage) { if (ModelState.IsValid) { string mediumName = "", largeName = ""; if (MediumImage != null) { mediumName = Path.GetFileName(MediumImage.FileName); string fileSavePath = "~/Images/Products/"; var path = Path.Combine(Server.MapPath(fileSavePath), mediumName); MediumImage.SaveAs(path); } if (LargeImage != null) { largeName = Path.GetFileName(LargeImage.FileName); string fileSavePath = "~/Images/Products/"; var path = Path.Combine(Server.MapPath(fileSavePath), largeName); LargeImage.SaveAs(path); } WaitoProduct product_db = new WaitoProduct() { Title = product.Title, ConsumerDetails = product.ConsumerDetail, Description = product.Description, IngredientList = product.IngredientList, Cooking = product.Cooking, LargeImage = largeName, MediumImage = mediumName, CreatedOn = DateTime.Now.Date, ModifiedOn = DateTime.Now.Date, CreatedBy = "Admin" }; using (WaitoEntities entities = new WaitoEntities()) { entities.WaitoProducts.Add(product_db); entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }
public ActionResult Create(Recipe recipe, HttpPostedFileBase MediumImage, HttpPostedFileBase LargeImage) { if (ModelState.IsValid) { string mediumName = "", largeName = ""; if (MediumImage != null) { mediumName = Path.GetFileName(MediumImage.FileName); string fileSavePath = "~/Images/Recipes/"; var path = Path.Combine(Server.MapPath(fileSavePath), mediumName); MediumImage.SaveAs(path); } if (LargeImage != null) { largeName = Path.GetFileName(LargeImage.FileName); string fileSavePath = "~/Images/Recipes/"; var path = Path.Combine(Server.MapPath(fileSavePath), largeName); LargeImage.SaveAs(path); } WaitoRecipe recipe_db = new WaitoRecipe() { Title = recipe.Title, Serves = recipe.Serves, Ingredients = recipe.Ingredient, Description = recipe.Description, MediumImage = mediumName, LargeImage = largeName, CreatedOn = DateTime.Now.Date, ModifiedOn = DateTime.Now.Date, CreatedBy = "Admin" }; using (WaitoEntities entities = new WaitoEntities()) { entities.WaitoRecipes.Add(recipe_db); entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }
public ActionResult Details(int id) { WaitoProduct product_db = new WaitoEntities().WaitoProducts.Where(p => p.ProductID == id).FirstOrDefault(); Product product = new Product() { ProductId = product_db.ProductID, Title = product_db.Title, ConsumerDetail = product_db.ConsumerDetails, Description = product_db.Description, IngredientList = product_db.IngredientList, Cooking = product_db.Cooking, MediumImage = product_db.MediumImage, LargeImage = product_db.LargeImage }; return View(product); }
public ActionResult Edit(Page page) { if (ModelState.IsValid) { using (WaitoEntities entities = new WaitoEntities()) { WaitoPage pages_db = entities.WaitoPages.Where(p => p.PageId == page.PageId).FirstOrDefault(); pages_db.PageName = page.PageName; pages_db.PageContent = page.PageContent; entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }
public ActionResult Create(Page page) { if (ModelState.IsValid) { using (WaitoEntities entities = new WaitoEntities()) { WaitoPage pages_db = new WaitoPage() { PageName = page.PageName, PageContent = page.PageContent }; entities.WaitoPages.Add(pages_db); entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }
public ActionResult Edit(Distributor distributor) { if (ModelState.IsValid) { using (WaitoEntities entities = new WaitoEntities()) { WaitoDistributor distributor_db = entities.WaitoDistributors.Where(d => d.DistributorId == distributor.DistributorId).FirstOrDefault(); distributor_db.Title = distributor.Title; distributor_db.Description = distributor.Description; distributor_db.Address = distributor.Address; distributor_db.Phone = distributor.Phone; entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }
public ActionResult Create(Distributor distributor) { if (ModelState.IsValid) { WaitoDistributor distributor_db = new WaitoDistributor() { Title = distributor.Title, Description = distributor.Description, Address = distributor.Address, Phone = distributor.Phone }; using (WaitoEntities entities = new WaitoEntities()) { entities.WaitoDistributors.Add(distributor_db); entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }
// // GET: /Product/ public ActionResult Index(int lastId=0, int firstId = 0) { List<Product> products = new List<Product>(); List<WaitoProduct> products_db; if (firstId > 0) { products_db = new WaitoEntities().WaitoProducts.Where(p => p.ProductID < firstId).OrderByDescending(p => p.ProductID).Take(4).ToList(); if (products_db == null || products_db.Count == 0) products_db = new WaitoEntities().WaitoProducts.OrderBy(p => p.ProductID).Take(4).ToList(); else products_db = products_db.OrderBy(p => p.ProductID).ToList(); } else if (lastId > 0) { products_db = new WaitoEntities().WaitoProducts.Where(p => p.ProductID > lastId).OrderBy(p => p.ProductID).Take(4).ToList(); if (products_db == null || products_db.Count == 0) products_db = new WaitoEntities().WaitoProducts.OrderBy(p => p.ProductID).Take(4).ToList(); } else { products_db = new WaitoEntities().WaitoProducts.OrderBy(p => p.ProductID).Take(4).ToList(); } foreach (var item in products_db) { products.Add( new Product() { ProductId = item.ProductID, Title = item.Title, ConsumerDetail = item.ConsumerDetails, Description = item.Description, IngredientList = item.IngredientList, Cooking = item.Cooking, MediumImage = item.MediumImage, LargeImage = item.LargeImage } ); } return View(products); }
// // GET: /Recipe/ public ActionResult Index(int lastId = 0, int firstId = 0) { List<Recipe> recipes = new List<Recipe>(); List<WaitoRecipe> recipes_db; if (firstId > 0) { recipes_db = new WaitoEntities().WaitoRecipes.Where(r => r.RecipeID < firstId).OrderByDescending(r => r.RecipeID).Take(4).ToList(); if (recipes_db == null || recipes_db.Count == 0) recipes_db = new WaitoEntities().WaitoRecipes.OrderBy(r => r.RecipeID).Take(4).ToList(); else recipes_db = recipes_db.OrderBy(r => r.RecipeID).ToList(); } else if (lastId > 0) { recipes_db = new WaitoEntities().WaitoRecipes.Where(r => r.RecipeID > lastId).OrderBy(r => r.RecipeID).Take(4).ToList(); if (recipes_db == null || recipes_db.Count == 0) recipes_db = new WaitoEntities().WaitoRecipes.OrderBy(r => r.RecipeID).Take(4).ToList(); } else { recipes_db = new WaitoEntities().WaitoRecipes.OrderBy(r => r.RecipeID).Take(4).ToList(); } foreach (var item in recipes_db) { recipes.Add( new Recipe() { RecipeId = item.RecipeID, Title = item.Title, Serves = item.Serves, Ingredient = item.Ingredients, Description = item.Description, MediumImage = item.MediumImage, LargeImage = item.LargeImage } ); } return View(recipes); }
// // GET: /StandardPages/ public ActionResult Index() { List<WaitoPage> pages_db = new WaitoEntities().WaitoPages.ToList(); return View(pages_db); }
// // GET: /Stockist/ public ActionResult Index() { List<WaitoDistributor> distributors = new WaitoEntities().WaitoDistributors.ToList(); return View(distributors); }
public ActionResult Edit(Product product, HttpPostedFileBase MediumImage, HttpPostedFileBase LargeImage) { if (ModelState.IsValid) { string mediumName = "", largeName = ""; if (MediumImage != null) { mediumName = Path.GetFileName(MediumImage.FileName); string fileSavePath = "~/Images/Products/"; var path = Path.Combine(Server.MapPath(fileSavePath), mediumName); MediumImage.SaveAs(path); } if (LargeImage != null) { largeName = Path.GetFileName(LargeImage.FileName); string fileSavePath = "~/Images/Products/"; var path = Path.Combine(Server.MapPath(fileSavePath), largeName); LargeImage.SaveAs(path); } using (WaitoEntities entities = new WaitoEntities()) { WaitoProduct product_db = entities.WaitoProducts.Where( p => p.ProductID == product.ProductId).FirstOrDefault(); product_db.Title = product.Title; product_db.ConsumerDetails = product.ConsumerDetail; product_db.Description = product.Description; product_db.IngredientList = product.IngredientList; product_db.Cooking = product.Cooking; product_db.LargeImage = largeName; product_db.MediumImage = mediumName; product_db.ModifiedOn = DateTime.Now.Date; product_db.ModifiedBy = "Admin"; entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }
public ActionResult Page(int id) { WaitoPage pages_db = new WaitoEntities().WaitoPages.Where(p => p.PageId == id).FirstOrDefault(); return View(pages_db); }
public ActionResult Edit(Recipe recipe, HttpPostedFileBase MediumImage, HttpPostedFileBase LargeImage) { if (ModelState.IsValid) { string mediumName = "", largeName = ""; if (MediumImage != null) { mediumName = Path.GetFileName(MediumImage.FileName); string fileSavePath = "~/Images/Recipes/"; var path = Path.Combine(Server.MapPath(fileSavePath), mediumName); MediumImage.SaveAs(path); } if (LargeImage != null) { largeName = Path.GetFileName(LargeImage.FileName); string fileSavePath = "~/Images/Recipes/"; var path = Path.Combine(Server.MapPath(fileSavePath), largeName); LargeImage.SaveAs(path); } using (WaitoEntities entities = new WaitoEntities()) { WaitoRecipe recipe_db = entities.WaitoRecipes.Where(r => r.RecipeID == recipe.RecipeId).FirstOrDefault(); recipe_db.Title = recipe.Title; recipe_db.Serves = recipe.Serves; recipe_db.Ingredients = recipe.Ingredient; recipe_db.Description = recipe.Description; recipe_db.MediumImage = mediumName; recipe_db.LargeImage = largeName; recipe_db.ModifiedOn = DateTime.Now.Date; recipe_db.ModifiedBy = "Admin"; entities.SaveChanges(); } return RedirectToAction("Index"); } return View(); }