Ejemplo n.º 1
0
        public bool updateMenuDetail(Menu_Detail item)
        {
            var mod = db.Menu_Detail.FirstOrDefault(n => n.id_menu_detail == item.id_menu_detail);

            mod.id_menu_detail    = item.id_menu_detail;
            mod.name_food_detail  = item.name_food_detail;
            mod.price_food_detail = item.price_food_detail;
            mod.id_menu           = item.id_menu;
            var path = "";
            HttpPostedFileBase file = Request.Files["photo"];

            if (file == null && file.ContentLength == 0)
            {
                mod.image_food_detail = mod.image_food_detail;
            }
            else
            {
                if (Path.GetExtension(file.FileName).ToLower() == ".jpg" || Path.GetExtension(file.FileName).ToLower() == ".png" || Path.GetExtension(file.FileName).ToLower() == ".jpeg" || Path.GetExtension(file.FileName).ToLower() == ".gif")
                {
                    path = Path.Combine(Server.MapPath("~/Image/menu-detail"), file.FileName);
                    file.SaveAs(path);
                    mod.image_food_detail = Convert.ToString(file.FileName);
                }
            }
            db.SaveChanges();
            return(true);
        }
Ejemplo n.º 2
0
        public bool deleteMenuDetail(int id_menu_detail)
        {
            Menu_Detail mod = db.Menu_Detail.FirstOrDefault(n => n.id_menu_detail == id_menu_detail);

            db.Menu_Detail.Remove(mod);
            db.SaveChanges();
            return(true);
        }
Ejemplo n.º 3
0
        public bool saveMenuDetail(Menu_Detail menuDetail)
        {
            Menu_Detail menuDetailItem = new Menu_Detail();

            menuDetailItem.name_food_detail  = menuDetail.name_food_detail;
            menuDetailItem.price_food_detail = menuDetail.price_food_detail;
            menuDetailItem.id_menu           = menuDetail.id_menu;
            var path = "";
            HttpPostedFileBase file = Request.Files["photo"];

            if (file != null && file.ContentLength > 0)
            {
                if (Path.GetExtension(file.FileName).ToLower() == ".jpg" || Path.GetExtension(file.FileName).ToLower() == ".png" || Path.GetExtension(file.FileName).ToLower() == ".jpeg" || Path.GetExtension(file.FileName).ToLower() == ".gif")
                {
                    path = Path.Combine(Server.MapPath("~/Image/menu-detail"), file.FileName);
                    file.SaveAs(path);
                }
            }
            menuDetailItem.image_food_detail = Convert.ToString(file.FileName);
            db.Menu_Detail.Add(menuDetailItem);
            db.SaveChanges();
            return(true);
        }