Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            DishEntry dishEntry = db.DishEntry.Find(id);

            db.DishEntry.Remove(dishEntry);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "Id,DishId,ProductId,Weight")] DishEntry dishEntry)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dishEntry).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DishId    = new SelectList(db.Dish, "Id", "Name", dishEntry.DishId);
     ViewBag.ProductId = new SelectList(db.Product, "Id", "Name", dishEntry.ProductId);
     return(View(dishEntry));
 }
Пример #3
0
        // GET: DishEntries/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DishEntry dishEntry = db.DishEntry.Find(id);

            if (dishEntry == null)
            {
                return(HttpNotFound());
            }
            return(View(dishEntry));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "Id,DishId,ProductId,Weight")] DishEntry dishEntry)
        {
            if (ModelState.IsValid)
            {
                db.DishEntry.Add(dishEntry);
                db.SaveChanges();
                //return RedirectToAction("Index");
            }
            IEnumerable <DishEntry> DishEntrys = db.DishEntry.Where(u => u.DishId == dishEntry.DishId).AsEnumerable();

            ViewBag.products  = DishEntrys;
            ViewBag.ProductId = new SelectList(db.Product, "Id", "Name", dishEntry.ProductId);
            dishEntry.Dish    = DishEntrys.FirstOrDefault().Dish;
            return(View(dishEntry));
        }
Пример #5
0
        // GET: DishEntries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DishEntry dishEntry = db.DishEntry.Find(id);

            if (dishEntry == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DishId    = new SelectList(db.Dish, "Id", "Name", dishEntry.DishId);
            ViewBag.ProductId = new SelectList(db.Product, "Id", "Name", dishEntry.ProductId);
            return(View(dishEntry));
        }
Пример #6
0
        // GET: DishEntries/Create
        public ActionResult Create(int?dishId)
        {
            if (dishId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //ViewBag.DishId = new SelectList(db.Dish, "Id", "Name");
            IEnumerable <DishEntry> DishEntrys = db.DishEntry.Where(u => u.DishId == dishId).AsEnumerable();

            ViewBag.products  = DishEntrys;
            ViewBag.ProductId = new SelectList(db.Product, "Id", "Name");
            DishEntry currentDishEntry = new DishEntry();

            currentDishEntry.Dish   = DishEntrys.FirstOrDefault().Dish;
            currentDishEntry.DishId = dishId ?? currentDishEntry.DishId;
            return(View(currentDishEntry));
        }