示例#1
0
        public ActionResult Create([Bind(Include = "Id,OrdId,DishId,Status")] Meals meals)
        {
            if (ModelState.IsValid)
            {

                Ord CurrentOrder = db.Ord.Find(meals.OrdId);
                if (CurrentOrder != null) {

                ViewBag.IsOrdClosed = false;
                if ( CurrentOrder.TimeEnd != null)
                    {
                        db.Meals.Add(meals);
                        CurrentOrder.TotalCost += db.Dish.Find(meals.DishId).Price;
                        db.Entry(CurrentOrder).State = EntityState.Modified;
                        db.SaveChanges();
                        ViewBag.IsOrdClosed = true;
                    }
            }
                //return RedirectToAction("Create", "Meals", new { ordId = meals.OrdId });
            }
            IEnumerable<Meals> MenuMeals = db.Meals.Where(u => u.OrdId == meals.OrdId).AsEnumerable();
            ViewBag.dishes = MenuMeals;
            ViewBag.DishId = new SelectList(db.Dish, "Id", "Name", meals.DishId);
            return View(meals);
        }
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
示例#3
0
        private long Save(long Id, ref Order orderToUpdate, StatusType statustype, FormCollection formcollection, OrderedProduct[] newItems, string Seats, OrderedProduct[] oldItems, int Status = 0)
        {
            //Alan for marketing System
            //RestaurantEntities db = new RestaurantEntities();
            //if (db.OrderedProducts.Count() > 200)
            //{
            //    return db.Orders.Max(o => o.Id);
            //}


            long           newId = 0;
            MembershipUser user  = Membership.GetUser(HttpContext.User.Identity.Name);

            if (Id == 0)
            {
                orderToUpdate = new Order()
                {
                    CreatedBy = (Guid)user.ProviderUserKey, CreatedDate = DateTime.Now
                };
            }
            else
            {
                orderToUpdate = db.Orders.Where(i => i.Id == Id).Single();
            }


            //if (TryUpdateModel(orderToUpdate, "", new string[] { "Status", "Seats", "TotalAmount" }
            //   ))
            //{
            if (oldItems != null)
            {
                UpdateDeletedItem(oldItems, orderToUpdate);
            }
            if (newItems != null)
            {
                UpdateOrderedProducts(newItems, orderToUpdate);
            }

            orderToUpdate.Seats = Seats;
            orderToUpdate.SetStatusType(statustype);
            if (Id == 0)
            {
                db.Entry(orderToUpdate).State = EntityState.Added;
            }
            else
            {
                db.Entry(orderToUpdate).State = EntityState.Modified;
            }

            db.SaveChanges();
            newId = db.Entry(orderToUpdate).Entity.Id;

            //}


            return(newId);
        }
示例#4
0
        public ActionResult cookitem(int id)
        {
            var data = db.OrderItem.Find(id);

            data.Status          = "Cook";
            db.Entry(data).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("index"));
        }
示例#5
0
        public ActionResult CloseOrd(int id)
        {
            Ord ord = db.Ord.Find(id);

            ord.TimeEnd         = DateTime.Now;
            db.Entry(ord).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#6
0
        public ResponseViewModel Pay(int id)
        {
            Bill bill = new Bill();

            bill.OrderID  = id;
            bill.BillDate = DateTime.Now;
            var orderitem = from a in db.OrderItem
                            where a.OrderID == id && a.IsDeleted != true && a.Status != "Cancel"
                            select a;
            double total = 0;

            foreach (var item in orderitem)
            {
                total                = total + (item.Qty * Convert.ToDouble(item.Menu.MenuPrice));
                item.Status          = "Paid";
                db.Entry(item).State = System.Data.Entity.EntityState.Modified;
            }
            total            = (total * 0.1) + total;
            bill.TotalPrice  = total.ToString();
            bill.CreatedBy   = "Admin";
            bill.CreatedDate = DateTime.Now;
            db.Bill.Add(bill);



            var order = db.Order.Find(id);

            order.Finish          = true;
            order.UpdateDate      = DateTime.Now;
            order.UpdatedBy       = "Admin";
            db.Entry(order).State = System.Data.Entity.EntityState.Modified;

            if (order.Type.TypeName == "Order")
            {
                var tableid = (from a in db.Track
                               where a.OrderID == order.OrderID
                               select a.TableID).FirstOrDefault();
                var table = db.Table.Find(tableid);
                table.TableStatus     = "NotOccupied";
                db.Entry(table).State = System.Data.Entity.EntityState.Modified;
            }
            if (db.SaveChanges() > 0)
            {
                return(new ResponseViewModel
                {
                    Status = true
                });
            }
            else
            {
                return(new ResponseViewModel
                {
                    Status = false
                });
            }
        }
示例#7
0
 public ActionResult EditDish([Bind(Include = "Id,Name,Cost,CategoryId,Descriprion,ImagePath")] Dish dish)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dish).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Dishes"));
     }
     ViewBag.CategoryId = new SelectList(db.DishCategories, "Id", "Name", dish.CategoryId);
     return(View(dish));
 }
示例#8
0
 public ActionResult Edit(ProductGroup productgroup)
 {
     if (ModelState.IsValid)
     {
         productgroup.ModifiedDate = DateTime.Now;
         db.ProductGroups.Attach(productgroup);
         //db.ObjectStateManager.ChangeObjectState(productgroup, EntityState.Modified);
         db.Entry(productgroup).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productgroup));
 }
示例#9
0
 public ActionResult Edit([Bind(Include = "CategoryID,CategoryName,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Category category)
 {
     if (ModelState.IsValid)
     {
         Category data = new Category();
         data = db.Category.Find(category.CategoryID);
         data.CategoryName    = category.CategoryName;
         data.UpdatedBy       = "Admin";
         data.UpdatedDate     = DateTime.Now;
         db.Entry(data).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
 public ActionResult Edit([Bind(Include = "StatusID,StatusName,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Status status)
 {
     if (ModelState.IsValid)
     {
         Status data = new Status();
         data                 = db.Status.Find(status.StatusID);
         data.StatusName      = status.StatusName;
         data.UpdatedBy       = "Admin";
         data.UpdatedDate     = DateTime.Now;
         db.Entry(data).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(status));
 }
 public ActionResult Edit([Bind(Include = "TypeID,TypeName,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Type type)
 {
     if (ModelState.IsValid)
     {
         Type data = new Type();
         data                 = db.Type.Find(type.TypeID);
         data.TypeName        = type.TypeName;
         data.UpdatedBy       = "Admin";
         data.UpdatedDate     = DateTime.Now;
         db.Entry(data).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(type));
 }
示例#12
0
        public ActionResult Edit([Bind(Include = "MenuID,MenuName,MenuPrice,MenuDescription,Content,ContentType,CategoryID,StatusID,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Menu menu, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                Menu data = new Menu();
                data                 = db.Menu.Find(menu.MenuID);
                data.MenuName        = menu.MenuName;
                data.MenuPrice       = menu.MenuPrice;
                data.MenuDescription = menu.MenuDescription;
                data.UpdatedBy       = "Admin";
                data.UpdatedDate     = DateTime.Now;
                data.StatusID        = menu.StatusID;
                data.CategoryID      = menu.CategoryID;

                if (upload != null)
                {
                    data.ContentType = upload.ContentType;
                    using (var reader = new System.IO.BinaryReader(upload.InputStream))
                    {
                        data.Content = reader.ReadBytes(upload.ContentLength);
                    }
                }
                db.Entry(data).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryID = new SelectList(db.Category, "CategoryID", "CategoryName", menu.CategoryID);
            ViewBag.StatusID   = new SelectList(db.Status, "StatusID", "StatusName", menu.StatusID);
            return(View(menu));
        }
示例#13
0
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != product.ProductId)
            {
                return(BadRequest());
            }

            db.Entry(product).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = product.ProductId }, product));
        }
 public ActionResult Edit([Bind(Include = "OrderID,OrderDate,TypeID,Finish,CreatedBy,CreatedDate,UpdatedBy,UpdateDate")] Order order)
 {
     if (ModelState.IsValid)
     {
         Order data = new Order();
         data                 = db.Order.Find(order.OrderID);
         data.UpdateDate      = DateTime.Now;
         data.UpdatedBy       = "Admin";
         data.TypeID          = order.TypeID;
         data.Finish          = order.Finish;
         db.Entry(data).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TypeID = new SelectList(db.Type, "TypeID", "TypeName", order.TypeID);
     return(View(order));
 }
示例#15
0
        public ActionResult Edit(Product product)
        {
            ViewBag.ProductGroup  = new SelectList(db.ProductGroups.Where(pg => pg.Status == true), "id", "Name");
            ViewBag.Kitchen       = new SelectList(db.Kitchens, "KitchenID", "KitchenName");
            ViewBag.MasterProduct = new SelectList(db.Products.Where(x => x.MasterProductID == null && x.Status == true), "id", "Name");
            if (ModelState.IsValid)
            {
                product.ModifiedDate = DateTime.Now;

                db.Products.Attach(product);


                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(product));
        }
 public ActionResult Edit([Bind(Include = "Id,Name")] RegUserRole regUserRole)
 {
     if (ModelState.IsValid)
     {
         db.Entry(regUserRole).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(regUserRole));
 }
示例#17
0
 public ActionResult Edit([Bind(Include = "MenuID,Name")] Menu menu)
 {
     if (ModelState.IsValid)
     {
         db.Entry(menu).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(menu));
 }
示例#18
0
 public ActionResult Edit([Bind(Include = "ID,Name,Cost,Quantity,Category")] Ingredients ingredients)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ingredients).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ingredients));
 }
 public ActionResult Edit([Bind(Include = "M_ID,M_P_ID,M_NAME,CONTROLLER_NAME,ACTION_NAME")] MENULISTA mENULISTA)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mENULISTA).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mENULISTA));
 }
示例#20
0
 public ActionResult Edit(CurrencyDenomination currencydenomination)
 {
     if (ModelState.IsValid)
     {
         db.Entry(currencydenomination).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(currencydenomination));
 }
示例#21
0
 public ActionResult Edit([Bind(Include = "ID,Name,Quantity")] UpdateSales inventory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(inventory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(inventory));
 }
示例#22
0
 public ActionResult Edit([Bind(Include = "Id,Number,PlaceNumber")] Tabl tabl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tabl).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tabl));
 }
示例#23
0
 public ActionResult Edit(Kitchen kitchen)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kitchen).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kitchen));
 }
示例#24
0
 public static bool SetTableBusy(int masaID)
 {
     using (RestaurantEntities db = new RestaurantEntities())
     {
         var f = db.Masa.Find(masaID);
         db.Entry(f).State = EntityState.Detached;
         var x = f.ConvertToTableModel();
         x.MasaDurumu = (int)Common.masaDurumu.Dolu;
         db.Entry(x.ConvertToMasa()).State = EntityState.Modified;
         if (db.SaveChanges() > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
 public ActionResult Edit([Bind(Include = "Id,Name")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
示例#26
0
 public ActionResult Edit(Printer printer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(printer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(printer));
 }
        public ActionResult Edit(MenuCards menucards)
        {
            if (ModelState.IsValid)
            {
                _restaurantEntities.Entry(menucards).State = EntityState.Modified;
                _restaurantEntities.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(menucards));
        }
        [HttpPost]                                   //ESTO SUCEDE CUANDO LA CONTROLLER RECIBE UN POST AL METODO EDIT
        public ActionResult Edit(CLIENTE objCliente) //RECIBE EL OBJETO POR PARAMETROS
        {
            if (ModelState.IsValid)
            {
                db.Entry(objCliente).State = EntityState.Modified; //SI VIENE CON CAMBIOS, SE QUEDARÁ CON LOS CAMBIOS REALIZADOS
                db.SaveChanges();                                  //CONSOLIDA EN LA BASE
                return(RedirectToAction("Index"));                 //REDIRIGE A LA VISTA DE LISTADO
            }

            return(View(objCliente)); //NO ENCONTRÓ COINCIDENCIAS NO RETORNA NADA
        }
        public ActionResult Edit(INSUMO objInsumo)
        {
            if (ModelState.IsValid)
            {
                db.Entry(objInsumo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(objInsumo));
        }
示例#30
0
        public ResponseViewModel ServedOrder(int id)
        {
            var orderitem = db.OrderItem.Find(id);

            if (orderitem.IsDeleted != true)
            {
                orderitem.Status          = "Served";
                db.Entry(orderitem).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(new ResponseViewModel {
                    Status = true
                });
            }
            else
            {
                return(new ResponseViewModel {
                    Status = false
                });;
            }
        }