예제 #1
0
        public ActionResult SubmitPackage(PackageInfoVM obj)
        {
            int numberOfTickets = CalculateNumberOfTickets(obj.composition);

            PackageCheckoutVM objToPass = new PackageCheckoutVM()
            {
                destCountry           = obj.flight.destinationCountry,
                hotelName             = obj.hotel.hotelName,
                numberOfRooms         = obj.hotel.numberOfRooms,
                roomDescription       = obj.hotel.room[0].roomDescription,
                composition           = obj.composition,
                departureFlightNumber = obj.flight.outbound.FlightNumber,
                returnFlightNumber    = obj.flight.inbound.FlightNumber,
                departureDate         = obj.flight.departureDate,
                returnDate            = obj.flight.returnDate,
                departureLocation     = obj.flight.originCity,
                returnLocation        = obj.flight.destinationCity,
                numberOfTickets       = numberOfTickets,
                airline  = obj.flight.airline,
                totalFee = obj.price.ToString(),
            };

            return(View("PackageCheckout", objToPass));
        }
예제 #2
0
        // ----------------------------- this view is only for static run (TEMP VIEW)
        public ActionResult ViewPackageInfo()
        {
            List <string> amenities = new List <string>();

            amenities.Add("Elevators");
            amenities.Add("Sauna");
            amenities.Add("Room service");
            amenities.Add("Internet services");
            amenities.Add("220 AC");
            amenities.Add("Parking");
            amenities.Add("Pets allowed");
            amenities.Add("Wireless internet connection in public areas");
            amenities.Add("Lounges/bars");
            amenities.Add("24-hour front desk");

            List <string> contacts = new List <string>();

            contacts.Add("PHONE: 49/8161/5320");
            contacts.Add("FAX: 49/8161/532100");
            contacts.Add("EMAIL: [email protected]");
            contacts.Add("URL: www.mercure.com");

            List <string> images = new List <string>();

            images.Add("https://maps.googleapis.com/maps/api/place/photo?maxwidth=800&photoreference=CmRaAAAAtIARwdNqhiQNC-jj-6upRvxxBXgk5Wdl_t484HkmD_ecnJrvi1wK3l53njD6C-XYc0dUEdEGg_SThMQJs7bZpb-2SpTAIUbRmTPoe2aOnpK7tIeC-oERWKsSjvS3H7eyEhA1a_4sr0mjoc7yFPpqvEFhGhSzrFsXmCqtC_7EZdfsvH1zdCjqEQ&key=AIzaSyCArIw-PoGMwSXFZr08nZT64BPDvix8w98");
            images.Add("https://maps.googleapis.com/maps/api/place/photo?maxwidth=800&photoreference=CmRaAAAA9zNoq-JwlWS9MkZCsM0FxyrXoogblHtJtoaPeJRzD2DZVWQS5qrq9vXYY7gCqS-MrEAd389xmp57gKYv7k1KzeqN7pO2Ufc1EUs6IxTX6D2541mMA-N5cAIVxf7ib_nbEhAoYFrmfqLRbhQbzIkNGqh3GhTk2uP9_DRnbDVmt_Nihbz0_ZDbIA&key=AIzaSyCArIw-PoGMwSXFZr08nZT64BPDvix8w98");

            List <string> roomType1 = new List <string>();

            roomType1.Add("Room type: Unspecified");
            roomType1.Add("Bed type: Double");
            roomType1.Add("Number of beds: 1");
            List <string> roomType2 = new List <string>();

            roomType2.Add("Room type: Unspecified");
            roomType2.Add("Bed type: Twin");
            roomType2.Add("Number of beds: 2");

            List <RoomVM> rooms = new List <RoomVM>();

            rooms.Add(new RoomVM()
            {
                roomDescription = "1 DOUBLE BED NONSMOKING FEEL YOURSELF AT HOME ",
                roomPrice       = 684.27,
                roomType        = roomType1
            });
            rooms.Add(new RoomVM()
            {
                roomDescription = "2 SINGLE BEDS NONSMOKING FEEL YOURSELF AT HOME ",
                roomPrice       = 684.27,
                roomType        = roomType1
            });

            HotelOrderDetailsVM hotel = new HotelOrderDetailsVM()
            {
                address       = "ADDRESS: Dr Von Daller Str 1 3, Freising",
                amenities     = amenities,
                apiKey        = "AIzaSyCArIw-PoGMwSXFZr08nZT64BPDvix8w98",
                contact       = contacts,
                hotelName     = "Mercure Muc Freising Airport",
                image         = images,
                latitude      = 48.40068,
                longitude     = 11.75076,
                rating        = "4",
                room          = rooms,
                reviews       = new List <HotelReview>(),
                customersName = new List <string>(),
            };

            FlightRouteVM inbound = new FlightRouteVM()
            {
                ArrivalAirportCode   = "TLV",
                ArrivalAirportName   = "Ben Gurion Airport",
                ArrivalDate          = "18.09.2018",
                ArrivalDay           = "Tuesday",
                ArrivalTime          = "03:35",
                DepartureAirportCode = "MUC",
                DepartureAirportName = "Munich International Airport",
                DepartureDate        = "17.09.2018",
                DepartureDay         = "Monday",
                DepartureTime        = "23:00",
                FlightNumber         = "680"
            };

            FlightRouteVM outbound = new FlightRouteVM()
            {
                ArrivalAirportCode   = "MUC",
                ArrivalAirportName   = "Munich International Airport",
                ArrivalDate          = "10.09.2018",
                ArrivalDay           = "Monday",
                ArrivalTime          = "09:55",
                DepartureAirportCode = "TLV",
                DepartureAirportName = "Ben Gurion Airport",
                DepartureDate        = "10.09.2018",
                DepartureDay         = "Monday",
                DepartureTime        = "06:55",
                FlightNumber         = "681"
            };

            FlightInfoVM flight = new FlightInfoVM()
            {
                airline             = "LH",
                departureDate       = "10.09.2018",
                destinationCity     = "Munich",
                destinationCodeCity = "MUC",
                destinationCountry  = "Germany",
                inbound             = inbound,
                originCity          = "Tel Aviv",
                originCodeCity      = "TLV",
                originCountry       = "Israel",
                outbound            = outbound,
                price                 = "555.07",
                returnDate            = "17.09.2018",
                seatsRemaining        = "9",
                timeDuration_outbound = ToolsClass.TimeDifferences("06:55", "09:55"),
                timeDuration_inbound  = ToolsClass.TimeDifferences("23:00", "03:35"),
            };

            PackageInfoVM package = new PackageInfoVM()
            {
                hotel       = hotel,
                flight      = flight,
                nights      = 7,
                price       = 3121.4,
                composition = "Couple",
            };

            return(View(package));
        }
예제 #3
0
        public ActionResult ViewPackageInfo(PackageDetailsVM obj)
        {
            var json = "";

            using (WebClient wc = new WebClient())
            {
                json = wc.DownloadString(obj.packages[obj.selectedPack].hotel.hotelLink).ToString();
            }
            dynamic results = JsonConvert.DeserializeObject(json);

            // save some data from json to list. later we will save this data in the object we will pass to the view
            List <string> contactLST   = HotelDetailsHelper1(results, "contacts");
            List <string> amenitiesLST = HotelDetailsHelper1(results, "amenities");
            List <RoomVM> roomLST      = HotelDetailsHelper2(results);

            if (roomLST.Count == 0) // we need to fix the api
            {
                roomLST = HotelDetailsHelper3(obj.packages[obj.selectedPack].hotel.originalLink, obj.selectedPack);
            }

            // ---------------------- load reviews
            DataLayer dl = new DataLayer();

            string hotelName = results.property_name;

            List <HotelReview> hotelReviewsList = (from u in dl.hotelReviews
                                                   where u.HotelName.ToLower() == hotelName.ToLower()
                                                   select u).ToList <HotelReview>();

            // search for customer name (by email)
            List <string> customersName = new List <string>();

            for (int i = 0; i < hotelReviewsList.Count; ++i)
            {
                string tempEmail    = hotelReviewsList[i].CustomerEmail;
                string customerName = (from u in dl.customers
                                       where u.Email.ToLower() == tempEmail.ToLower()
                                       select u.FullName).ToList <string>()[0];
                customersName.Add(customerName);
            }
            // -------------------------------------


            // get image by GoogleAPI
            ImageSearch image = new ImageSearch();

            try
            {
                image.SetHotelName(results.property_name.ToString()); // initialize object by GoogleAPI
                image.SavePhotoReferences();
            }
            catch (Exception)
            {
                Thread.Sleep(1000);
                return(ViewPackageInfo(obj));
            }

            List <string> imageLST = image.GetImages();

            HotelOrderDetailsVM hotel = new HotelOrderDetailsVM()
            {
                hotelName     = results.property_name,
                address       = "ADDRESS: " + results.address.line1 + ", " + results.address.city,
                contact       = contactLST,
                amenities     = amenitiesLST,
                rating        = obj.packages[obj.selectedPack].hotel.rating.ToString(),
                latitude      = results.location.latitude,
                longitude     = results.location.longitude,
                room          = roomLST,
                image         = imageLST,
                apiKey        = image.GetKey(),
                reviews       = hotelReviewsList,
                customersName = customersName,
            };

            obj.packages[obj.selectedPack].flight.timeDuration_outbound = ToolsClass.TimeDifferences(obj.packages[obj.selectedPack].flight.outbound.DepartureTime, obj.packages[obj.selectedPack].flight.outbound.ArrivalTime);
            obj.packages[obj.selectedPack].flight.timeDuration_inbound  = ToolsClass.TimeDifferences(obj.packages[obj.selectedPack].flight.inbound.DepartureTime, obj.packages[obj.selectedPack].flight.inbound.ArrivalTime);

            FlightInfoVM flight = obj.packages[obj.selectedPack].flight;


            PackageInfoVM package = new PackageInfoVM()
            {
                hotel       = hotel,
                flight      = flight,
                nights      = obj.nights,
                price       = obj.packages[obj.selectedPack].price,
                composition = obj.composition,
            };

            return(View(package));
        }