Esempio n. 1
0
        public ActionResult ManageOrders()
        {
            List <GetOrders_Result> ResOrders;
            List <OrderToDisplay>   Orders          = new List <OrderToDisplay>();
            List <OrderToDisplay>   CancelledOrders = new List <OrderToDisplay>();

            ResOrders = _context.GetOrders().ToList();
            foreach (GetOrders_Result r in ResOrders)
            {
                var CurRoom = _context.GetRoomById(r.RoomId).FirstOrDefault();

                OrderToDisplay OrderVM = new OrderToDisplay
                {
                    ID          = r.ID,
                    Username    = UserMgr.FindById(r.UserId).UserName,
                    RoomNo      = CurRoom.RoomNo,
                    FromDate    = r.FromDate,
                    ToDate      = r.ToDate,
                    IsCancelled = r.IsCancelled ? "Cancelled" : "Normal",
                    UnitPrice   = CurRoom.Price,
                    TotalCost   = r.TotalCost
                };
                if (!r.IsCancelled)
                {
                    Orders.Add(OrderVM);
                }
                else
                {
                    CancelledOrders.Add(OrderVM);
                }
            }

            var tables = new ManageOrdersViewModel
            {
                Orders          = Orders,
                CancelledOrders = CancelledOrders
            };

            return(View(tables));
        }