Esempio n. 1
0
        public ActionResult AddHotel(HotelDetailsViewModel hotelDetailsViewModel, List <HttpPostedFileBase> files)
        {
            if (true)
            {
                hotelDetailsViewModel.Hotel.HotelImage = new List <HotelImage>();

                //HttpPostedFileBase file = Request.Files["ProfilePicture"];
                var path = SaveFileToDirectory(Request.Files["ProfilePicture"]);
                hotelDetailsViewModel.Hotel.ProfilePicSource = path;
                hotelDetailsViewModel.Hotel.HotelImage.Add(new HotelImage
                {
                    ImageSource = path
                });

                foreach (var file in files)
                {
                    path = SaveFileToDirectory(file);
                    hotelDetailsViewModel.Hotel.HotelImage.Add(new HotelImage
                    {
                        ImageSource = path
                    });
                }

                _hotelService.AddHotel(hotelDetailsViewModel);
            }
            ViewBag.DestinationId = new SelectList(_destinationService.GetAll(), "Id", "Name");
            ViewBag.RoomTypeId    = new SelectList(_hotelService.GetAllRoomTypes(), "Id", "TypeName");
            /*return View();*/
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 2
0
        public static void LoadWorld(HotelService hotelService, FactTypeService factTypeService, int maxHotels)
        {
            var world = Download <World>("http://api.thomascook.se/v-1/geography/world");

            List <Hotel> hotels = new List <Hotel>();

            FindHotels(hotels, world, maxHotels);

            Console.WriteLine("\n\nAdding FactTypes");
            Dictionary <string, FactTypeModel> factTypeDictionary = new Dictionary <string, FactTypeModel>();

            foreach (var fact in hotels.SelectMany(h => h.Facts))
            {
                FactTypeModel model;
                if (!factTypeDictionary.TryGetValue(fact.Type, out model))
                {
                    model = factTypeService.GetFactType(fact.Type);
                    if (model == null)
                    {
                        model = new FactTypeModel()
                        {
                            Code = fact.Type, Name = fact.Title
                        };
                        var id = factTypeService.AddFactType(model);
                        model.Id = id;
                    }
                    factTypeDictionary[fact.Type] = model;
                }
            }
            Console.WriteLine("\n\nAdding hotels");
            foreach (var hotel in hotels)
            {
                Console.WriteLine("Adding hotel {0}", hotel.Name);
                var id = hotelService.AddHotel(hotel.Name, hotel.Description.Select(d => d.Text).FirstOrDefault(), hotel.ResortName,
                                               hotel.Images != null && hotel.Images.Main != null
                                                   ? hotel.Images.Main.Select(
                                                   i =>
                                                   i.OrderByDescending(ii => ii.Width).Select(ii => ii.Href).FirstOrDefault())
                                               .FirstOrDefault()
                                                   : null, hotel.Location != null ? hotel.Location.Latitude : 0,
                                               hotel.Location != null ? hotel.Location.Longitude : 0);

                Console.WriteLine("Setting facts for hotel {0}", hotel.Name);
                hotelService.SetHotelFacts(id, from f in hotel.Facts
                                           select
                                           new FactModel(factTypeDictionary[f.Type].Id, f.Type, f.Title,
                                                         f.Value.Trim() != "-" && f.Value.Trim().ToLower() != "false",
                                                         f.Value.ToLower() == "false" || f.Value.ToLower() == "true"
                                                                     ? string.Empty
                                                                     : f.Value));
            }
        }
 protected override void When()
 {
     _returnValue = _hotelService.AddHotel("Test Beach Hotel", "A nice hotel situated right at Test Beach", "Test Beach", "http://test.com/test.jpg", 0.0f, 0.0f);
 }
        public void SeedTableHotelsInBulgaria()
        {
            hotelService.AddHotel("Bulgaria", "Sofia", "Grand Hotel Sofia", 5, 150);
            hotelService.AddHotel("Bulgaria", "Sofia", "InterContinental", 5, 160);
            hotelService.AddHotel("Bulgaria", "Sofia", "Acord", 3, 60);
            hotelService.AddHotel("Bulgaria", "Sofia", "Hilton", 5, 150);
            hotelService.AddHotel("Bulgaria", "Sofia", "Lion", 3, 65);

            hotelService.AddHotel("Bulgaria", "Plovdiv", "Hotel Plovdiv", 3, 55);
            hotelService.AddHotel("Bulgaria", "Plovdiv", "Trimontium", 4, 70);
            hotelService.AddHotel("Bulgaria", "Plovdiv", "Hotel Zdravets", 3, 60);

            hotelService.AddHotel("Bulgaria", "Burgas", "Sunny", 3, 40);
            hotelService.AddHotel("Bulgaria", "Burgas", "Burgas Beach", 4, 70);
            hotelService.AddHotel("Bulgaria", "Burgas", "Atlantis Resort", 4, 75);
            hotelService.AddHotel("Bulgaria", "Burgas", "St Anastasia", 4, 95);

            hotelService.AddHotel("Bulgaria", "Varna", "South Bay", 4, 100);
            hotelService.AddHotel("Bulgaria", "Varna", "Galeria", 4, 105);
            hotelService.AddHotel("Bulgaria", "Varna", "Victoria", 3, 60);

            hotelService.AddHotel("Bulgaria", "Sunny Beach", "Grand Victoria", 4, 100);
            hotelService.AddHotel("Bulgaria", "Sunny Beach", "Jasmine", 3, 65);
            hotelService.AddHotel("Bulgaria", "Sunny Beach", "Majestic", 5, 150);
            hotelService.AddHotel("Bulgaria", "Sunny Beach", "Baikal", 4, 75);
            hotelService.AddHotel("Bulgaria", "Sunny Beach", "Trakia", 3, 55);

            hotelService.AddHotel("Bulgaria", "Nessebar", "Sol Nessebar Palace", 5, 145);
            hotelService.AddHotel("Bulgaria", "Nessebar", "Dolphin", 3, 45);
            hotelService.AddHotel("Bulgaria", "Nessebar", "Zlatna Ribka", 3, 40);
            hotelService.AddHotel("Bulgaria", "Nessebar", "Festa Panorama", 4, 110);

            hotelService.AddHotel("Bulgaria", "Bansko", "Maria Antoaneta", 3, 45);
            hotelService.AddHotel("Bulgaria", "Bansko", "Grand Hotel Bansko", 4, 55);
            hotelService.AddHotel("Bulgaria", "Bansko", "Campanella", 3, 60);

            hotelService.AddHotel("Bulgaria", "Borovets", "Lion", 4, 40);
            hotelService.AddHotel("Bulgaria", "Borovets", "Samokov", 3, 40);
            hotelService.AddHotel("Bulgaria", "Borovets", "Borovets Hills", 5, 100);
            hotelService.AddHotel("Bulgaria", "Borovets", "Flora", 4, 50);

            hotelService.AddHotel("Bulgaria", "Velingrad", "Select", 4, 65);
            hotelService.AddHotel("Bulgaria", "Velingrad", "Zdravets", 3, 55);
            hotelService.AddHotel("Bulgaria", "Velingrad", "Olymp", 4, 70);
        }