// Delete Food Items
        public ActionResult DeleteFoodItems(int id)
        {
            FoodItem f = db.FoodItems.Find(id);

            db.FoodItems.Remove(f);
            db.SaveChanges();
            ViewBag.listProduct = db.FoodItems.ToList();

            return(View());
        }
Beispiel #2
0
        public ActionResult Register(UserAccount acc)
        {
            try
            {
                var db = new DB26Entities5();


                Person p = new Person();
                p.First_Name    = acc.First_Name;
                p.Last_Name     = acc.Last_Name;
                p.Cell_No       = acc.Cell_No;
                p.Email         = acc.Email;
                p.Password      = acc.Password;
                p.Discriminator = acc.Discriminator;
                p.Address       = acc.Address;


                db.People.Add(p);
                db.SaveChanges();

                ViewBag.Meassgae = acc.First_Name + " " + acc.Last_Name + "successfully registered";

                return(RedirectToAction("Index"));
            }

            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
        }
        // Change Status from not deliver to deliver when food is prepared
        public ActionResult changestatusList(int Id)
        {
            Order f = db.Orders.Find(Id);

            f.Status = "Deliver";
            db.SaveChanges();
            List <Order> po = new List <Order>();

            foreach (Order p in db.Orders)
            {
                if (p.Status == "Deliver")
                {
                    Order p1 = new Order();
                    p1.OrderID    = p.OrderID;
                    p1.Order_Date = p.Order_Date;
                    p1.Items      = p.Items;
                    p1.Status     = p.Status;
                    po.Add(p1);
                }
            }
            ViewBag.listProduct = po;
            return(View());
        }
        public ActionResult ManageFoodItems(Addfooditem obj, HttpPostedFileBase image1)
        {
            try
            {
                var db = new DB26Entities5();


                FoodItem food = new FoodItem();
                food.Name     = obj.Name;
                food.Price    = obj.Price;
                food.Category = obj.Category;
                food.Picture  = new byte[image1.ContentLength];
                image1.InputStream.Read(food.Picture, 0, image1.ContentLength);


                db.FoodItems.Add(food);
                db.SaveChanges();
                return(RedirectToAction("ManageFoodItems"));
            }

            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
        }
Beispiel #5
0
        public ActionResult TrackOrder(string id)
        {
            try
            {
                if (id == "")
                {
                    return(HttpNotFound());
                }
                else
                {
                    CurrentOrderTrackID = Convert.ToInt32(id);
                    Order            order       = new Order();
                    List <OrderFood> productlist = new List <OrderFood>();
                    foreach (OrderFood Order in db.OrderFoods)
                    {
                        if (Order.OrderID == Convert.ToInt32(id))
                        {
                            OrderFood Oproduct = new OrderFood();
                            //Oproduct.Order.Status = Order.Order.Status;
                            Oproduct.OrderID     = Order.OrderID;
                            Oproduct.ProductID   = Order.ProductID;
                            Oproduct.Price       = Order.Price;
                            Oproduct.Category    = Order.Category;
                            Oproduct.ProductName = Order.ProductName;
                            Oproduct.Quantity    = Order.Quantity;
                            productlist.Add(Oproduct);

                            cancelview can = new cancelview();
                            can.OrderID  = Order.OrderID;
                            can.FoodID   = Order.ProductID;
                            can.Quantity = Order.Quantity;
                            db.SaveChanges();
                        }
                    }
                    int r = Convert.ToInt32(id);
                    order = db.Orders.Find(Convert.ToInt32(id));
                    if (order == null)
                    {
                        ViewBag.NULL = true;
                    }
                    else
                    {
                        ViewBag.orderStatus = order.Status;
                    }
                    ViewBag.Filterthroughid = productlist;
                    return(View(productlist.ToList()));
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
        }