コード例 #1
0
        public IActionResult Index()
        {
            //put all the reservation from the database in a model list
            List <BookingDetailModel> ALLreservations = _context.Reservations.Select(r => new BookingDetailModel()
            {
                //Sitting
                SittingID   = r.SittingID,
                SittingName = r.Sitting.SittingName,

                //Reservation
                ReservationID          = r.ReservationID,
                NumberOfGuests         = r.NumberOfGuests,
                AdditionalRequirements = r.AdditionalRequirements,
                Date      = r.Date,
                StartTime = r.StartTime,
                EndTime   = r.EndTime,
                Status    = r.Status,
                Source    = r.Source,

                //Customer
                CustomerId = r.Customer.CustomerID,
                FirstName  = r.Customer.FirstName,

                //tables
                NumberOfTables = r.Table_Reservation.Count
                                 //order it based on its date
            }).OrderByDescending(r => r.Date).ToList();

            //set the area for each reservation
            foreach (var reservation in ALLreservations)
            {
                //get the area name based on the reservation ID
                reservation.Area = _services.GetAreaByID(reservation.ReservationID);
            }
            //send the list model with data to the View
            return(View(ALLreservations));
        }
コード例 #2
0
        public async Task <IActionResult> OnGetAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }
            Customer c = _services.GetCustomerByEmail(user.Email);

            try
            {
                MyReservations = _context.Reservations.Select(r => new ReservationModel()
                {
                    //Sitting
                    SittingID   = r.SittingID,
                    SittingName = r.Sitting.SittingName,

                    //Reservation
                    ReservationID          = r.ReservationID,
                    NumberOfGuests         = r.NumberOfGuests,
                    AdditionalRequirements = r.AdditionalRequirements,
                    Date      = r.Date,
                    StartTime = r.StartTime,
                    EndTime   = r.EndTime,
                    Status    = r.Status,

                    //Customer
                    CustomerId = r.Customer.CustomerID,
                    FirstName  = r.Customer.FirstName,
                    LastName   = r.Customer.LastName,

                    //tables
                    NumberOfTables = r.Table_Reservation.Count,
                }).Where(r => r.CustomerId == c.CustomerID).OrderByDescending(r => r.Date).ToList();

                foreach (var i in MyReservations)
                {
                    i.Area = _services.GetAreaByID(i.ReservationID);
                }
            }
            catch
            {
                MyReservations = new List <ReservationModel>();
            }

            return(Page());
        }
コード例 #3
0
        public IActionResult MReservations()
        {
            var Customers              = _context.Customers.ToList();
            var Reservations           = _context.Reservations.ToList();
            var Table_Reservationsoles = _context.Table_Reservations.ToList();
            var tables   = _context.Tables.ToList();
            var Sittings = _context.Sittings.ToList();
            //Getting all the reservations from the database in a model list.
            List <BookingDetailModel> items = _context.Reservations.Select(r => new BookingDetailModel()
            {
                //Sitting
                SittingID   = r.SittingID,
                SittingName = r.Sitting.SittingName,

                //Reservation
                ReservationID          = r.ReservationID,
                NumberOfGuests         = r.NumberOfGuests,
                AdditionalRequirements = r.AdditionalRequirements,
                Date      = r.Date,
                StartTime = r.StartTime,
                EndTime   = r.EndTime,
                Status    = r.Status, //Pending, confirmed, seated, completed, cancelled
                Source    = r.Source, //Website, phone, in person, email etc...

                //Customer
                CustomerId = r.Customer.CustomerID,
                FirstName  = r.Customer.FirstName,

                //tables
                NumberOfTables = r.Table_Reservation.Count,
                //ordering the list by Date in descending order.
            }).OrderByDescending(r => r.Date).ToList();

            //Setting the area for the reservations.
            foreach (var i in items)
            {
                //Getting the area name based on the ReservationID
                i.Area = _services.GetAreaByID(i.ReservationID);
            }
            //Sending the populated model to the view
            return(View(items));
        }