//public bool HotelsDelete(int id)
        //{
        //    const string sql = "delete from Hotels where Id={0}";
        //    return context.Database.ExecuteSqlCommand(sql,id)>0;
        //}


        public bool HotelsRegister(HotelsViewModel hotels)
        {
            DateTime     dateTime = DateTime.Now;
            const string sql      = "insert into Hotels(HotelPhoto,HotelName,HotelAddress,FoundationYear,IsAktive,CreatedOn,CountryId,RegionId,CityId,DistrictId) Values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10})";

            return(context.Database.ExecuteSqlCommand(sql, hotels.HotelPhoto, hotels.HotelName, hotels.HotelAddress, hotels.FoundationYear, hotels.IsAktive, dateTime, hotels.CountryId, hotels.RegionId, hotels.CityId, hotels.DistrictId) > 0);
        }
Пример #2
0
        public ActionResult Hotels(int id)
        {
            tblStadService stadservice = new tblStadService();

            HotelsViewModel vm = new HotelsViewModel();

            tblHotelService hotelservice = new tblHotelService();

            tblHotel[] hotels = hotelservice.getHotelsByStad(id);
            vm.hotelID       = hotels.Select(a => a.HotelID).ToArray();
            vm.hotelnaam     = hotels.Select(a => a.Naam).ToArray();
            vm.hoteladres    = hotels.Select(a => a.Adres).ToArray();
            vm.prijspernacht = hotels.Select(a => a.PrijsPerOvernachting).ToArray();
            vm.hotelfoto     = hotels.Select(a => a.HotelFoto).ToArray();
            vm.stadNaam      = stadservice.getStad(id).Naam;
            if (TempData.Peek("namen") != null)
            {
                Debug.WriteLine("namen: " + (string[])TempData.Peek("namen"));
                vm.namen = (string[])TempData.Peek("namen");
            }
            if (TempData.Peek("datum") != null)
            {
                Debug.WriteLine("datum: " + (string)TempData.Peek("datum"));
                vm.datum = DateTime.ParseExact((string)TempData.Peek("datum"), "MM/dd/yyyy", CultureInfo.InvariantCulture);
            }
            return(View(vm));
        }
Пример #3
0
        public IActionResult Filter(HotelsViewModel hotelsViewModel)
        {
            var hotelListAfterSearch = hotelsViewModel.Hotels ??
                                       GetHotelsBySearch(
                HttpContext.Session.GetString("SearchKeyword"),
                Convert.ToDateTime(JsonConvert.DeserializeObject(HttpContext.Session.GetString("CheckInDate"))),
                Convert.ToDateTime(JsonConvert.DeserializeObject(HttpContext.Session.GetString("CheckOutDate")))
                );

            var facilitiesList = hotelsViewModel.Facilities;
            var starList       = hotelsViewModel.StarsList;
            var distanceList   = hotelsViewModel.DistanceList;

            var hotelListAfterFilter = hotelListAfterSearch
                                       .Where(h => starList != null ? starList.All(s => h.Stars.ToString().Contains(s)) : true)
                                       .Where(h => facilitiesList != null ? facilitiesList.All(f => h.HotelFacilities.Select(f => f.FacilityId.ToString()).Contains(f)) : true)
                                       .Where(h => distanceList != null ? h.DistanceFromCenter < distanceList.Max() : true)
                                       .ToList();

            string     currentUserId = GetCurrentUserId();
            List <int> hotelIdList   = GetHotelIdList(currentUserId);

            var newHotelViewModel = new HotelsViewModel
            {
                SearchKeyword  = HttpContext.Session.GetString("SearchKeyword"),
                CheckIn        = Convert.ToDateTime(JsonConvert.DeserializeObject(HttpContext.Session.GetString("CheckInDate"))),
                CheckOut       = Convert.ToDateTime(JsonConvert.DeserializeObject(HttpContext.Session.GetString("CheckOutDate"))),
                FavoriteHotels = hotelIdList,
                Hotels         = hotelListAfterFilter
            };

            FillingViewBags();

            return(View("Index", newHotelViewModel));
        }
Пример #4
0
        public IActionResult Index(bool clear)
        {
            string     currentUserId = GetCurrentUserId();
            List <int> hotelIdList   = GetHotelIdList(currentUserId);

            var hotelsViewModel = new HotelsViewModel()
            {
                Hotels = _appContext.Hotels
                         .Include(h => h.Rooms)
                         .Include(h => h.HotelFacilities).ThenInclude(hf => hf.Facility),
                FavoriteHotels = hotelIdList
            };

            FillingViewBags();
            if (HttpContext.Session.GetString("SearchKeyword") == null || clear)
            {
                HttpContext.Session.SetString("SearchKeyword", string.Empty);
            }
            if (HttpContext.Session.GetString("CheckInDate") == null || clear)
            {
                HttpContext.Session.SetString("CheckInDate", JsonConvert.SerializeObject(null));
            }
            if (HttpContext.Session.GetString("CheckOutDate") == null || clear)
            {
                HttpContext.Session.SetString("CheckOutDate", JsonConvert.SerializeObject(null));
            }

            return(View(hotelsViewModel));
        }
        public ActionResult RegisterHotel()
        {
            Listes();
            HotelsViewModel hvm = new HotelsViewModel();

            return(View(hvm));
        }
Пример #6
0
 public ActionResult Viesbucio_informacijos_langas(int id = 0)
 {
     try
     {
         Viesbutis            hotel = repository.Set <Viesbutis>().Find(id);
         List <RoomViewModel> rooms = new List <RoomViewModel>();
         List <Kambarys>      items = repository.Set <Kambarys>().ToList();
         foreach (var item in items)
         {
             if (item.fk_Viesbutisid == id)
             {
                 rooms.Add(new RoomViewModel()
                 {
                     id          = item.id,
                     Capacity    = item.vietu_sk,
                     Number      = item.numeris,
                     Price       = item.kaina,
                     Description = item.aprasymas,
                     Type        = item.tipas.name.First().ToString().ToUpper() + item.tipas.name.Substring(1)
                 });
             }
         }
         rooms.OrderBy(x => x.id);
         List <ServiceViewModel>   services = new List <ServiceViewModel>();
         List <Papildoma_paslauga> items2   = repository.Set <Papildoma_paslauga>().ToList();
         foreach (var item in items2)
         {
             if (item.fk_Viesbutisid == id)
             {
                 services.Add(new ServiceViewModel()
                 {
                     id          = item.id,
                     Description = item.aprasymas,
                     Price       = item.kaina
                 });
             }
         }
         services.OrderBy(x => x.id);
         var model = new HotelsViewModel();
         if (hotel != null)
         {
             model.id          = hotel.id;
             model.Title       = hotel.pavadinimas;
             model.HotelsNet   = hotel.viesbuciu_tinklas;
             model.Stars       = hotel.zvaigzduciu_sk;
             model.City        = hotel.miestas;
             model.Address     = hotel.adresas;
             model.Description = hotel.aprasymas;
         }
         model.Rooms         = rooms;
         model.Services      = services;
         model.RoomsTitle    = new RoomViewModel();
         model.ServicesTitle = new ServiceViewModel();
         return(View(model));
     }
     catch (ITPProException ex)
     {
         return(RedirectToAction("Sistemos_klientu_langas"));
     }
 }
        public ActionResult RegisterHotel(HotelsViewModel hotels)
        {
            if (hotels.Id == 0)
            {
                if (Request.Files.Count > 0)
                {
                    if (Request.Files[0].FileName == "")
                    {
                        hotels.HotelPhoto = "HotelNull.png";
                    }
                    else if (Request.Files[0].FileName != "")
                    {
                        string Dosyaadi = Guid.NewGuid().ToString();
                        string Uzanti   = Path.GetExtension(Request.Files[0].FileName);
                        string Yol      = "~/img/Hotels/" + Dosyaadi + Uzanti;
                        Request.Files[0].SaveAs(Server.MapPath(Yol));
                        hotels.HotelPhoto = Dosyaadi + Uzanti;
                    }
                }

                hotelsManager.HotelsRegister(hotels);
            }
            else
            {
                var kontrol = hotelsManager.ListAll(x => x.Id == hotels.Id).FirstOrDefault();
                if (kontrol != null)
                {
                    if (Request.Files.Count > 0)
                    {
                        if (kontrol.HotelPhoto == "" || kontrol.HotelPhoto == null && Request.Files[0].FileName == "")
                        {
                            hotels.HotelPhoto = "~/img/Hotel/HotelNull.png";
                        }
                        else if (Request.Files[0].FileName != "")
                        {
                            string Dosyaadi = Guid.NewGuid().ToString();
                            string Uzanti   = Path.GetExtension(Request.Files[0].FileName);
                            string Yol      = "~/img/Hotel/" + Dosyaadi + Uzanti;
                            Request.Files[0].SaveAs(Server.MapPath(Yol));
                            hotels.HotelPhoto = Dosyaadi + Uzanti;
                        }
                    }

                    hotelsManager.HotelsUpdate(hotels);
                }
            }



            Listes();
            return(View());
        }
Пример #8
0
        private IEnumerable <Hotel> GetHotelsBySearch(string searchKeyword, DateTime checkInDate, DateTime checkOutDate)
        {
            if (searchKeyword != null && searchKeyword != string.Empty)
            {
                var hotelsViewModel = new HotelsViewModel
                {
                    Hotels = _appContext.Hotels
                             .Include(h => h.HotelFacilities)
                             .Include(h => h.Rooms)
                             .Where(h => h.Name.Contains(searchKeyword) ||
                                    h.City.Contains(searchKeyword))
                             .ToList()
                };

                if (checkInDate != DateTime.MinValue && checkOutDate != DateTime.MinValue)
                {
                    var stay = new List <DateTime>();
                    for (DateTime date = checkInDate; date < checkOutDate; date = date.AddDays(1))
                    {
                        stay.Add(date);
                    }

                    var unavailableRooms = _appContext.Rooms
                                           .Where(r => _appContext.BookedRooms
                                                  .Any(b => b.RoomId == r.RoomId && stay.Contains(b.Date)));

                    var availableRooms = _appContext.Rooms
                                         .Except(unavailableRooms);

                    var availableHotels = availableRooms
                                          .Select(r => r.Hotel)
                                          .Distinct()
                                          .ToList();

                    hotelsViewModel.Hotels = hotelsViewModel.Hotels
                                             .Where(h1 => availableHotels
                                                    .Any(h2 => h2.HotelId == h1.HotelId))
                                             .ToList();
                }

                return(hotelsViewModel.Hotels);
            }
            return(_appContext.Hotels
                   .Include(h => h.Rooms)
                   .Include(h => h.HotelFacilities)
                   .ThenInclude(hf => hf.Facility)
                   .ToList());
        }
Пример #9
0
        // GET api/Hotel


        public IEnumerable <HotelsViewModel> GetHotels()
        {
            var _hotels = new List <HotelsViewModel>();

            foreach (var p in db.Hotels.ToList())
            {
                var _newobj = new HotelsViewModel();
                _newobj.Images       = new List <hotelImagesViewModel>();
                _newobj.HotelId      = p.HotelId;
                _newobj.Name         = p.Name;
                _newobj.Description  = p.Description;
                _newobj.Address      = p.Address;
                _newobj.city         = p.city;
                _newobj.Contact      = p.Contact;
                _newobj.facebooklink = p.facebooklink;
                _newobj.twitterlink  = p.twitterlink;
                _newobj.websiteurl   = p.websiteurl;
                _newobj.Pincode      = p.Pincode;
                _newobj.Notes        = p.Notes;
                _newobj.Latitude     = p.Latitude;
                _newobj.longitude    = p.longitude;



                _newobj.HotelType     = p.HotelType;
                _newobj.instagramlink = p.instagramlink;

                if (p.Rooms != null && p.Rooms.Count() > 0)
                {
                }

                if (p.Images != null && p.Images.Count() > 0)
                {
                    foreach (var k in p.Images.ToList())
                    {
                        var _newimage = new hotelImagesViewModel();
                        _newimage.ImageID   = k.ImageID;
                        _newimage.HotelID   = k.HotelID;
                        _newimage.ImageData = k.Imagedata;
                        _newobj.Images.Add(_newimage);
                    }
                }

                _hotels.Add(_newobj);
            }
            return(_hotels.ToList());
        }
Пример #10
0
        public ActionResult Hotels(HotelsViewModel model)
        {
            for (int i = 0; i < model.namen.Count(); i++)
            {
                Debug.WriteLine("hotelIDs: " + model.hotelID);
                var claimsIdentity = User.Identity as ClaimsIdentity;
                if (claimsIdentity != null)
                {
                    var userIdClaim = claimsIdentity.Claims
                                      .FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier);

                    if (userIdClaim != null)
                    {
                        int hotelid = 999999999;
                        if (Request.Form["0"] != null)
                        {
                            hotelid = model.hotelID[0];
                        }
                        else if (Request.Form["1"] != null)
                        {
                            hotelid = model.hotelID[1];
                        }
                        else if (Request.Form["2"] != null)
                        {
                            Debug.WriteLine(model.hotelID.Count());
                            hotelid = model.hotelID[2];
                        }
                        Debug.WriteLine(hotelid);
                        tblProductService        productservice        = new tblProductService();
                        tblProduct               product               = productservice.getProductByHotel(hotelid);
                        string                   id                    = userIdClaim.Value;
                        tblWinkelmandlijnService winkelmandlijnservice = new tblWinkelmandlijnService();
                        tblWinkelmandlijn        winkelmandlijn        = new tblWinkelmandlijn();
                        winkelmandlijn.GebruikersID = id;
                        winkelmandlijn.ProductID    = product.ProductID;
                        winkelmandlijn.Naam         = model.namen[i];
                        winkelmandlijn.Datum        = model.datum;
                        winkelmandlijnservice.addWinkelmandLijn(winkelmandlijn);
                    }
                }
            }


            return(RedirectToAction("Index", "Home"));
        }
Пример #11
0
        public ActionResult Index()
        {
            var hotels = new HotelsViewModel();

            hotels.Collection = new List <HotelViewModel>();

            var dbHotels = this.hotelsService
                           .GetAll()
                           //.Select(x => new HotelViewModel(x))
                           .ToList();

            foreach (var dbHotel in dbHotels)
            {
                var hotel = new HotelViewModel(dbHotel);
                hotels.Collection.Add(hotel);
            }

            return(View(hotels.Collection));
        }
Пример #12
0
        public ActionResult Browse(float?price, int?estrellas, string ciudad, string distrito)
        {
            HotelsViewModel hotelviewmodel = new HotelsViewModel();

            try
            {
                if (price.HasValue)
                {
                    if (estrellas.HasValue || ciudad != "" || distrito != "")
                    {
                        hotelviewmodel.ListaHoteles = AllHotels(price.Value, estrellas.HasValue?estrellas.Value:5, ciudad, distrito);
                        hotelviewmodel.estrellas    = estrellas.HasValue ? estrellas.Value : 5;
                        hotelviewmodel.ciudad       = ciudad;
                        hotelviewmodel.distrito     = distrito;
                    }
                    else
                    {
                        hotelviewmodel.ListaHoteles = AllHotels(price.Value);
                    }
                }
                else
                {
                    hotelviewmodel.ListaHoteles = AllHotels();
                }



                hotelviewmodel.Precio = price.Value;

                return(View(hotelviewmodel));
            }
            catch
            {
                return(View(hotelviewmodel));
            }



            return(View(hotelviewmodel));
        }
        public IActionResult Favorites()
        {
            string currentUserId = GetCurrentUserId();
            var    currentUser   = _appContext.ApplicationUsers.Where(u => u.Id == currentUserId).FirstOrDefault();

            ViewBag.User = currentUser;
            var newHotelsList = _appContext.HotelUsers
                                .Where(x => x.UserId == currentUserId)
                                .Include(hu => hu.Hotel)
                                .ThenInclude(h => h.HotelFacilities)
                                .ThenInclude(hf => hf.Facility)
                                .Select(x => x.Hotel)
                                .ToList();
            List <int> hotelIdList       = GetHotelIdList(currentUserId);
            var        newHotelViewModel = new HotelsViewModel
            {
                Hotels         = newHotelsList,
                FavoriteHotels = hotelIdList
            };

            return(View(newHotelViewModel));
        }
Пример #14
0
        public IActionResult Search(HotelsViewModel hotelsViewModel)
        {
            if (hotelsViewModel.SearchKeyword != null)
            {
                HttpContext.Session.SetString("SearchKeyword", hotelsViewModel.SearchKeyword);
            }
            if (hotelsViewModel.CheckIn != DateTime.MinValue)
            {
                HttpContext.Session.SetString("CheckInDate", JsonConvert.SerializeObject(hotelsViewModel.CheckIn));
            }
            if (hotelsViewModel.CheckOut != DateTime.MinValue)
            {
                HttpContext.Session.SetString("CheckOutDate", JsonConvert.SerializeObject(hotelsViewModel.CheckOut));
            }

            string     currentUserId = GetCurrentUserId();
            List <int> hotelIdList   = GetHotelIdList(currentUserId);

            var hotelListAfterSearch = GetHotelsBySearch(
                HttpContext.Session.GetString("SearchKeyword"),
                Convert.ToDateTime(JsonConvert.DeserializeObject(HttpContext.Session.GetString("CheckInDate"))),
                Convert.ToDateTime(JsonConvert.DeserializeObject(HttpContext.Session.GetString("CheckOutDate")))
                );

            var newHotelViewModel = new HotelsViewModel
            {
                SearchKeyword  = HttpContext.Session.GetString("SearchKeyword"),
                CheckIn        = Convert.ToDateTime(JsonConvert.DeserializeObject(HttpContext.Session.GetString("CheckInDate"))),
                CheckOut       = Convert.ToDateTime(JsonConvert.DeserializeObject(HttpContext.Session.GetString("CheckOutDate"))),
                FavoriteHotels = hotelIdList,
                Hotels         = hotelListAfterSearch
            };

            FillingViewBags();

            return(Filter(newHotelViewModel));
        }
Пример #15
0
        public ActionResult Viesbuciu_langas(int page = 1, int items = 10)
        {
            if (page < 1)
            {
                page = 1;
            }

            ViewData["page"]  = page;
            ViewData["items"] = items;
            Darbuotojas            emp    = repository.Set <Darbuotojas>().Find(CurrentUser.UserId);
            Viesbutis              hotel  = repository.Set <Viesbutis>().Find(emp.fk_Viesbutisid);
            HotelsViewModel        model  = new HotelsViewModel();
            List <HotelsViewModel> hotels = new List <HotelsViewModel>();
            List <Teises>          rights = repository.Set <Teises>().Where(x => x.fk_Darbuotojasdarbuojo_kodas == CurrentUser.UserId).ToList();

            foreach (var item in repository.Set <Viesbutis>())
            {
                if (item.viesbuciu_tinklas == hotel.viesbuciu_tinklas)
                {
                    hotels.Add(new HotelsViewModel()
                    {
                        id          = item.id,
                        Title       = item.pavadinimas,
                        HotelsNet   = item.viesbuciu_tinklas,
                        Stars       = item.zvaigzduciu_sk,
                        City        = item.miestas,
                        Address     = item.adresas,
                        Description = item.aprasymas,
                        Rights      = rights.Where(x => x.viesbutis == item.pavadinimas).Select(x => x.teisiu_statusas).FirstOrDefault()
                    });
                }
            }
            hotels.OrderBy(x => x.id);
            model.hotels = hotels.ToPagedList(1, 10);

            return(View(model));
        }
Пример #16
0
 public bool HotelsUpdate(HotelsViewModel hotels)
 {
     return(efHotelsRepository.HotelsUpdate(hotels));
 }
Пример #17
0
 public bool HotelsRegister(HotelsViewModel hotels)
 {
     return(efHotelsRepository.HotelsRegister(hotels));
 }
Пример #18
0
        public ActionResult Hotels()
        {
            HotelsViewModel viewModel = new HotelsViewModel();

            return(PartialView("_Hotels", viewModel));
        }
        public bool HotelsUpdate(HotelsViewModel hotels)
        {
            const string sql = "update Hotels set HotelPhoto={0},HotelName={1},HotelAddress={2},FoundationYear={3},IsAktive={4},Regionid={5},Cityid={6},Districtid={7},CountryId={8} where Id ={9}";

            return(context.Database.ExecuteSqlCommand(sql, hotels.HotelPhoto, hotels.HotelName, hotels.HotelAddress, hotels.FoundationYear, hotels.IsAktive, hotels.RegionId, hotels.CityId, hotels.DistrictId, hotels.CountryId, hotels.Id) > 0);
        }
Пример #20
0
 private void FillGrid()
 {
     hvm = new HotelsViewModel();
     DataGridHotels.ItemsSource = null;
     DataGridHotels.ItemsSource = hvm.Hotels;
 }