public ActionResult Kitchen(DateTime givenDate)
        {
            //DateTime date = DateTime.Today;
            if (givenDate.Year == 1)
            {
                givenDate = DateTime.Today;
            }



            var viewModel = new AllBookings
            {
                CheckedIn = _context.CheckIns.ToList()
                ,
                Booked = _context.Bookings.ToList()
            };

            viewModel.Date = givenDate;


            viewModel.CheckedIn = viewModel.CheckedIn.Where
                                      (i => i.Date.Day == givenDate.Day).ToList();
            viewModel.CheckedInAdults = 0;
            viewModel.CheckedInKids   = 0;
            viewModel.TotalCheckedIn  = 0;
            foreach (var guest in viewModel.CheckedIn)
            {
                viewModel.CheckedInAdults += guest.Adults;
                viewModel.CheckedInKids   += guest.Kids;
                viewModel.TotalCheckedIn   = guest.Kids + guest.Adults;
            }

            viewModel.Booked = viewModel.Booked.Where
                                   (i => i.Date.Day == givenDate.Day).ToList();
            viewModel.BookedAdults = 0;
            viewModel.BookedKids   = 0;
            viewModel.TotalBooked  = 0;
            foreach (var guest in viewModel.Booked)
            {
                viewModel.BookedAdults += guest.Adults;
                viewModel.BookedKids   += guest.Kids;
                viewModel.TotalBooked   = guest.Kids + guest.Adults;
            }

            return(View(viewModel));
        }
示例#2
0
        public List <AllBookings> GetAllBookings()
        {
            try
            {
                SqlConnection      sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationDbContext"].ConnectionString);
                SqlCommand         cmd           = new SqlCommand();
                List <AllBookings> bookings      = new List <AllBookings>();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT DISTINCT Booking.bookingId, Booking.totalPrice, hp.personName AS hairdresserName, cp.personName AS customerName, BookingTime.date_, BookingTime.startTime, Service_.serviceType " +
                                  "FROM Booking b," +
                                  "Person hp JOIN HairDresser ON hp.personId = HairDresser.personHairDresserId " +
                                  "JOIN Booking ON HairDresser.hairDresserId = Booking.hairdressId, " +
                                  "Person cp JOIN Customer ON cp.personId = Customer.customerPersonId " +
                                  "JOIN Booking bc ON Customer.customerId = bc.customerId, " +
                                  "BookingTime JOIN Booking bt ON BookingTime.bookingTimeId = bt.bookingTimeBookingId, " +
                                  "Service_ JOIN Booking_Service ON Service_.serviceId = Booking_Service.bookingService_ServiceId JOIN Booking bs ON Booking_Service.bookingService_BookingId = bs.bookingId " +
                                  "WHERE Booking.bookingId = Booking.bookingId";

                cmd.Connection = sqlConnection;
                cmd.Connection.Open();
                var dbReader = cmd.ExecuteReader();

                AllBookings b;

                while (dbReader.Read())
                {
                    b = new AllBookings(dbReader["hairdresserName"].ToString(),
                                        dbReader["customerName"].ToString(),
                                        dbReader["date_"].ToString(),
                                        dbReader["startTime"].ToString(),
                                        dbReader["serviceType"].ToString(),
                                        Convert.ToInt32(dbReader["bookingId"]),
                                        Convert.ToDouble(dbReader["totalPrice"]));

                    bookings.Add(b);
                }
                dbReader.Close();
                sqlConnection.Close();
                return(bookings);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public BookingDetailsPage(AllBookings allBookings)
        {
            InitializeComponent();

            TopImage.Source = allBookings.details.image;
            TopText.Text    = allBookings.details.name;
            TopSubText.Text = allBookings.booking_unique_id;
            string[] tokens = allBookings.booking_data_time.Split(' ');
            TransactionDate.Text   = tokens[0];
            TicketNumber.Text      = allBookings.booking_details.total_number_seat + " ticket(s) booked";
            TranscationAmount.Text = allBookings.booking_details.paid_amount;
            DateBookedeFor.Text    = allBookings.booking_details.booking_date_for;
            BookedTimeFor.Text     = allBookings.booking_details.booking_time_for;
            Location.Text          = allBookings.details.vanue_details.location + allBookings.details.vanue_details.picklocation;

            var html1 = new HtmlWebViewSource
            {
                Html = "<iframe width=\"100%\" height=\"200\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src = \"https://maps.google.com/maps?q=" + allBookings.details.vanue_details.latitude + "," + allBookings.details.vanue_details.latitude + "&hl=es;z=14&amp;output=embed\" ></ iframe > "
            };

            BookingLocDesc.Source = html1;
        }