示例#1
0
        public ActionResult Index()
        {
            List <Meal>      meals      = mRepo.GetCurrent();
            List <MealModel> mealmodels = new List <MealModel>();

            meals.ForEach(m => mealmodels.Add(new MealModel {
                ID = m.ID, Description = m.Description, Name = m.Name, PhotoPath = m.PhotoPath, Quantity = (int)m.Stock, Price = (int)m.Price
            }));
            return(View(mealmodels.ToPagedList(1, 1000)));
        }
示例#2
0
 // GET: Admin/Admin
 public ActionResult Index()
 {
     if (Session["UserID"] != null && Session["UserType"].ToString().ToLower() == "admin")
     {
         List <Meal>      meals      = mRepo.GetCurrent();
         List <MealModel> mealmodels = new List <MealModel>();
         meals.ForEach(m => mealmodels.Add(new MealModel {
             ID = m.ID, Description = m.Description, Name = m.Name, PhotoPath = m.PhotoPath, Quantity = (int)m.Stock, Price = (int)m.Price
         }));
         return(View(mealmodels.ToPagedList(1, 1000)));
     }
     return(RedirectToAction("Login", "Home", new { area = "" }));
 }
示例#3
0
        public ActionResult Scan(int?id)
        {
            if (Session["UserID"] != null && Session["UserType"].ToString().ToLower() == "chef")
            {
                if (id == null)
                {
                    return(RedirectToAction("Index"));
                }
                Order ord = oRepo.GetByID((int)id);

                List <DAL.User>         users         = uRepo.GetCurrent();
                List <DAL.Meal>         meals         = mRepo.GetCurrent();
                List <DAL.OrderProduct> orderProducts = opRepo.GetCurrent();
                OrderModel om = new OrderModel();

                if (ord.Date != null)
                {
                    om.Date = (DateTime)ord.Date;
                }
                else
                {
                    om.Date = new DateTime();
                }

                om.EstimatedTime = ord.EstimatedTime;
                om.ID            = ord.ID;
                om.QRCodePath    = ord.QRCodePath;
                om.TotalPrice    = ord.TotalPrice;
                om.Voucher       = null;

                UserModel um = new UserModel();
                if (ord.UserID != null)
                {
                    var usr = uRepo.GetByID((int)ord.UserID);
                    if (usr.DOB != null)
                    {
                        um.DOB = (DateTime)usr.DOB;
                    }
                    else
                    {
                        um.DOB = new DateTime();
                    }

                    um.ID       = usr.ID;
                    um.Mail     = usr.Mail;
                    um.Name     = usr.Name;
                    um.NrOrders = usr.NrOrders;
                    um.Type     = usr.Type;
                }

                om.User = um;

                List <MealModel> mm = new List <MealModel>();
                foreach (DAL.OrderProduct op in orderProducts)
                {
                    if (op.OrderID == ord.ID)
                    {
                        MealModel mealmodel = new MealModel();
                        Meal      meal      = mRepo.GetByID((int)op.MealID);
                        mealmodel.ID   = meal.ID;
                        mealmodel.Name = meal.Name;
                        if (op.Quantity == null)
                        {
                            mealmodel.Quantity = 0;
                        }
                        else
                        {
                            mealmodel.Quantity = (int)op.Quantity;
                        }
                        mm.Add(mealmodel);
                    }
                }
                om.Meals = mm;

                Session["ordID"] = id;
                return(View(om));
            }
            return(RedirectToAction("Login", "Home", new { area = "" }));
        }