예제 #1
0
        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");
        }
예제 #2
0
        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");
        }
예제 #3
0
        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");
        }
예제 #4
0
        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();
        }
예제 #5
0
        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();
        }
예제 #6
0
        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();
        }
예제 #7
0
        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();
        }
예제 #8
0
        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();
        }
예제 #9
0
        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();
        }
예제 #10
0
        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();
        }
예제 #11
0
        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();
        }