[Authorize] //view the specific client orders.
        public ActionResult AllOrders()
        {
            var userMail = (string)Session["Email"];
            var user     = umanager.Users.Where(u => u.Email == userMail).FirstOrDefault();
            var orders   = manager.Orders;
            List <MyOrdersVM> myOrders = new List <MyOrdersVM>();

            foreach (var item in orders)
            {
                if (item.UserID == user.UserID)
                {
                    MyOrdersVM myOrder = new MyOrdersVM
                    {
                        UserID       = item.UserID,
                        OrderID      = item.OrderID,
                        StartDate    = item.StartDate,
                        Picture      = item.Movies.Picture,
                        MovieName    = item.Movies.MovieName,
                        CategoryName = item.Movies.Categorys.CategoryName,
                        Price        = item.Movies.Prices.Price
                    };
                    myOrders.Add(myOrder);
                }
                ;
            }
            return(View(myOrders));
        }
Esempio n. 2
0
        public ActionResult Orders()
        {
            OrderBL    orderBL = new OrderBL();
            MyOrdersVM list    = new MyOrdersVM();

            list.orders = orderBL.GetOrders();

            return(View(list));
        }
Esempio n. 3
0
        public ActionResult MyOrders()
        {
            OrderBL      orderBL  = new OrderBL();
            List <Order> list     = orderBL.GetOrders();
            string       user     = Session["login"].ToString();
            MyOrdersVM   myorders = new MyOrdersVM();
            List <Order> tmp      = new List <Models.Order>();

            foreach (Order o in list)
            {
                if (o.username == user)
                {
                    tmp.Add(o);
                }
            }
            myorders.orders = tmp;

            return(View(myorders));
        }
Esempio n. 4
0
        public async Task <IActionResult> AllRentals()
        {
            // Get the current user
            var user = await GetCurrentUserAsync();

            var ViewModel = new MyOrdersVM
            {
                OpenOrders   = new List <Order>(),
                ClosedOrders = new List <Order>(),
            };


            //var applicationDbContext = _context.Gears.Include(g => g.Category).Include(g => g.Condition).Include(g => g.Orders).Where(g => g.User == user);

            var openOrders = await _context.Orders
                             .Include(o => o.Gear)
                             .Include(o => o.Borrower)
                             .Where(o => o.Borrower == user && o.Completed == false).ToListAsync();

            var closedOrders = await _context.Orders
                               .Include(o => o.Gear)
                               .Include(o => o.Borrower)
                               .Where(o => o.Borrower == user && o.Completed == true).ToListAsync();

            ViewModel.OpenOrdersTotal   = openOrders.Sum(c => c.Gear.RentalPrice);
            ViewModel.ClosedOrdersTotal = closedOrders.Sum(c => c.Gear.RentalPrice);

            ViewModel.OpenOrders   = openOrders;
            ViewModel.ClosedOrders = closedOrders;

            return(View(ViewModel));


            //var user = await GetCurrentUserAsync();

            //var applicationDbContext = _context.Orders.Include(o => o.Borrower).Include(o => o.Gear).Include(o => o.Renter).Where(o => o.RenterId == user.Id);
            //return View(await applicationDbContext.ToListAsync());
        }