public ActionResult Edit(HotelViewModel fvm, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                Image = Request.Files["Image"];
            }


            MemoryStream target = new MemoryStream();

            Image.InputStream.CopyTo(target);


            byte[] trtr;

            trtr = target.ToArray();

            hotel h = new hotel()
            {
                name        = fvm.name,
                adresse     = fvm.adresse,
                description = fvm.description,
                longitude   = fvm.longitude,
                latitude    = fvm.latitude,
                pic         = trtr,
                star        = fvm.star,
                roomNumber  = fvm.roomNumber
            };


            a.addHotel(h);


            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public async Task <IHttpActionResult> CreateHotel(HotelViewModel hotel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            TestDBEntities db = new TestDBEntities();

            var exist = await db.Hotels
                        .AnyAsync(h => h.Name.Equals(hotel.Name, StringComparison.InvariantCultureIgnoreCase));

            if (exist)
            {
                return(BadRequest("Object already exist"));
            }

            var newHotel = new Hotel
            {
                Name       = hotel.Name,
                Date       = DateTime.Now,
                LastUpdate = DateTime.Now
            };

            db.Hotels.Add(newHotel);
            await db.SaveChangesAsync();

            var location = Request.RequestUri + newHotel.ID.ToString();

            return(Created(location, newHotel));
        }
Exemple #3
0
        public IActionResult Create([FromForm] HotelViewModel model)
        {
            if (String.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError(nameof(HotelViewModel.Name), "The Name field is required.");
            }

            if (String.IsNullOrEmpty(model.Description))
            {
                ModelState.AddModelError(nameof(HotelViewModel.Description), "The Description field is required.");
            }

            if (ModelState.IsValid)
            {
                var hotel   = _mapper.Map <HotelViewModel, Hotel>(model);
                var hotelId = Guid.NewGuid();
                hotel.Id = hotelId;

                //if (!String.IsNullOrEmpty(model.Room))
                //{
                //    var room = _roomService.GetRoomByName(model.Room);
                //}

                _hotelService.Create(hotel);

                return(StatusCode(201));
            }

            return(StatusCode(400));
        }
        public ActionResult Create(HotelViewModel fvm, HttpPostedFileBase Image)
        {
            //  if (!ModelState.IsValid || Image == null || Image.ContentLength == 0)
            //    {
            //    return RedirectToAction("Create");
            //  }

            Image = Request.Files["Image"];


            MemoryStream target = new MemoryStream();

            Image.InputStream.CopyTo(target);


            byte[] trtr;

            trtr = target.ToArray();

            hotel h = new hotel()
            {
                name        = fvm.name,
                adresse     = fvm.adresse,
                description = fvm.description,
                longitude   = fvm.longitude,
                latitude    = fvm.latitude,
                pic         = trtr,
                star        = fvm.star,
                roomNumber  = fvm.roomNumber
            };

            a.addHotel(h);

            return(RedirectToAction("Index"));
        }
        public JsonResult UpdateHotel(HotelViewModel hViewModel)
        {
            try
            {
                Set_Date_Session(hViewModel.Hotel);

                _hRepo.UpdateHotel(hViewModel.Hotel);

                _hRepo.DeleteHotelFacilities(hViewModel.Hotel.HotelId);

                hViewModel.HotelFacilityDetails = _hRepo.GetHotelFacilities(hViewModel.Hotel.HotelId);

                hViewModel.FriendlyMessage.Add(MessageStore.Get("HM02"));

                Logger.Debug("Hotel Controller Update HotelBasicDetails");
            }
            catch (Exception ex)
            {
                hViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Hotel Controller - Update HotelBasicDetails " + ex.Message);
            }

            return(Json(hViewModel));
        }
        public JsonResult GetHotelBank(HotelViewModel hViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            pager = hViewModel.Pager;

            PaginationViewModel pViewModel = new PaginationViewModel();

            try
            {
                pViewModel.dt = _hRepo.GetHotelBank(hViewModel.HotelBank.HotelId, ref pager);

                pViewModel.Pager = pager;

                Logger.Debug("Hotel Controller GetHotelBank");
            }

            catch (Exception ex)
            {
                hViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Hotel Controller - GetHotelBank" + ex.ToString());
            }

            return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet));
        }
        public JsonResult AddBookingFromSearch(SearchModel searchModel)
        {
            HotelViewModel hotelModel = repository.GetAllHotels().SingleOrDefault(x => x.Id == searchModel.HotelId);

            BookingModel bookingModel = new BookingModel();

            bookingModel.HotelId        = hotelModel.Id;
            bookingModel.InvoiceNumber  = "HMB" + new Guid();
            bookingModel.FromDate       = searchModel.FromDate;
            bookingModel.ToDate         = searchModel.ToDate;
            bookingModel.Adult          = searchModel.Adult;
            bookingModel.Children       = searchModel.Children;
            bookingModel.BuyingCurrency = hotelModel.DefaultCurrency;
            bookingModel.BookingDate    = DateTime.Now.ToString("dd/mm/yyyy");
            if (searchModel.CalculatedNight > 0)
            {
                bookingModel.BuyingPrice = hotelModel.PricePerNight * searchModel.CalculatedNight;
            }
            else
            {
                bookingModel.BuyingPrice = hotelModel.PricePerNight;
            }

            string data = repository.AddBooking(bookingModel);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #8
0
        public async Task <IHttpActionResult> EditHotel(int id, HotelViewModel hotel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            TestDBEntities db = new TestDBEntities();

            var existingHotel = await db.Hotels.Where(h => h.ID == id).SingleOrDefaultAsync();

            if (existingHotel == null)
            {
                return(BadRequest("Object not found"));
            }

            existingHotel.Name       = hotel.Name;
            existingHotel.LastUpdate = DateTime.Now;

            db.Hotels.Attach(existingHotel);
            var entry = db.Entry(existingHotel);

            entry.Property(h => h.Name).IsModified       = true;
            entry.Property(h => h.LastUpdate).IsModified = true;
            await db.SaveChangesAsync();

            return(Ok());
        }
Exemple #9
0
 public IEnumerable <HotelViewModel> GetAllHotels()
 {
     using (HotelDBContext _hotelEntities = new HotelDBContext())
     {
         var data = _hotelEntities.Hotels.ToList();
         List <HotelViewModel> hotelList = new List <HotelViewModel>();
         for (var i = 0; i < data.Count; i++)
         {
             HotelViewModel hotelView = new HotelViewModel();
             hotelView.Id                 = data[i].Id;
             hotelView.HotelName          = data[i].HotelName;
             hotelView.Address            = data[i].Address;
             hotelView.PhoneNumber        = data[i].PhoneNumber;
             hotelView.CancellationPolicy = data[i].CancellationPolicy;
             hotelView.Description        = data[i].Description;
             hotelView.CountryId          = Convert.ToInt32(data[i].CountryId);
             CountryModel countryModel = GetAllCountry().SingleOrDefault(x => x.Id == hotelView.CountryId);
             hotelView.CountryName = countryModel.CountryName;
             hotelView.CityId      = Convert.ToInt32(data[i].CityId);
             CityModel cityModel = GetAllCity().SingleOrDefault(x => x.Id == hotelView.CityId);
             hotelView.CityName        = cityModel.CityName;
             hotelView.PricePerNight   = Convert.ToDecimal(data[i].PricePerNight);
             hotelView.DefaultCurrency = data[i].DefaultCurrency;
             hotelList.Add(hotelView);
         }
         return(hotelList);
     }
 }
Exemple #10
0
        public List <string> Validate(IFormFileCollection files, HotelViewModel newHotel)
        {
            foreach (var file in files)
            {
                if (CheckImageExtension(file))
                {
                    if (file.Length < fourMegaByte)
                    {
                        return(newHotel.ErrorMessages);
                    }
                    else
                    {
                        newHotel.ErrorMessages.Add("The image max 4 MB");
                        return(newHotel.ErrorMessages);
                    }
                }
                else
                {
                    newHotel.ErrorMessages.Add("Please add only image formats!");
                    return(newHotel.ErrorMessages);
                }
            }

            return(newHotel.ErrorMessages);
        }
        // GET: HotelController/Details/
        public ActionResult Details(int id)
        {
            var hotelViewModel = new HotelViewModel();

            hotelViewModel.Hotel = hotelRepository.Get(id);
            return(View(hotelViewModel));
        }
Exemple #12
0
        public ActionResult ActualizarHotel(Guid?id)
        {
            if (id == null)
            {
                TempData["mensaje"] = $"No se envia identificador";
                return(RedirectToAction("Index"));
            }
            Hotel hotel = _hotelService.GetHotelById(id);

            if (hotel == null)
            {
                TempData["mensaje"] = $"El hotel no se encuentra registrado";
                return(RedirectToAction("Index"));
            }
            var            tipoHotel = _hotelService.GetAllTipoHoles();
            var            ciudades  = _hotelService.GetAllCiudades();
            HotelViewModel model     = new HotelViewModel()
            {
                Id            = hotel.Id,
                Nombre        = hotel.Nombre,
                Descripcion   = hotel.Descripcion,
                CupoMaximo    = hotel.CupoMaximo,
                ListTipoHotel = new SelectList(tipoHotel, "Id", "Nombre"),
                ListCiudades  = new SelectList(ciudades, "Id", "Nombre")
            };

            return(View(model));
        }
Exemple #13
0
        public async Task <IActionResult> Edit(int id, HotelViewModel hotelViewModel)
        {
            if (id != hotelViewModel.Id)
            {
                return(this.NotFound());
            }

            if (!this.ModelState.IsValid)
            {
                this.ViewData["DestinationId"] = new SelectList(this.destinationsService.GetAll(), "Id", "Town", hotelViewModel.DestinationId);

                return(this.View(hotelViewModel));
            }

            try
            {
                await this.hotelsService.EditAsync(id, hotelViewModel);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!this.HotelExists(hotelViewModel.Id))
                {
                    return(this.NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(this.RedirectToAction(nameof(this.Index)));
        }
        public ActionResult IndexForAdmin()
        {
            var hotelViewModel = new HotelViewModel();

            hotelViewModel.Hotels = hotelRepository.GetAll();
            return(View(hotelViewModel));
        }
Exemple #15
0
        public ActionResult Users_Login(string email, string password)
        {
            Users user = usersrepo.Login(email, password);

            if (!user.IsActive)
            {
                ViewBag.Message = "This Account is not Verified. Please go to your registered E-mail Account in order to Verify.";
                return(View("Users_Login"));
            }
            Session["roleId"]   = user.RoleId;
            Session["userName"] = user.UserName;
            Session["userId"]   = user.UserId;
            if (user.RoleId == 1)
            {
                return(View("Dashboard"));
            }
            else if (user.RoleId == 2)
            {
                HotelViewModel visitorViewModel = new HotelViewModel();
                visitorViewModel.hotels = hotelsrepo.Read();
                visitorViewModel.rooms  = roomrepo.Read();
                visitorViewModel.types  = typesrepo.Read();
                visitorViewModel.users  = usersrepo.Read();
                return(View("Visitor_Dashboard", visitorViewModel));
            }
            else if (user.RoleId == 0)
            {
                return(View("Dashboard"));
            }
            ViewBag.Message = "Incorrect E-mail or Password";
            return(View("Users_Login"));
        }
Exemple #16
0
        public ActionResult Edit(HotelViewModel model)
        {
            if (ModelState.IsValid)
            {
                var fileName = string.Empty;

                if (model.Image != null)
                {
                    // extract only the fielname
                    fileName = Path.GetFileName(model.Image.FileName);
                    // store the file inside ~/Content/HotelImages folder
                    var path = Path.Combine(Server.MapPath("~/Content/HotelImages"), fileName);
                    model.Image.SaveAs(path);
                }

                HotelManager manager = new HotelManager();
                Hotel        hotel   = new Hotel();
                hotel.Id          = model.Id;
                hotel.Name        = model.Name;
                hotel.Description = model.Description;
                hotel.City        = model.City;
                hotel.Address     = model.Address;
                hotel.HouseNumber = model.HouseNumber;
                hotel.IsActive    = model.IsActive;
                hotel.Image       = string.IsNullOrEmpty(fileName) ? null : "/Content/HotelImages/" + fileName;

                manager.Edit(hotel);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Exemple #17
0
        public ActionResult EditHoteById(Guid hotelId)
        {
            HotelViewModel viewModel  = new HotelViewModel();
            Hotel          foundHotel = db.Hotels.ToList().Where(x => x.HotelId == hotelId).FirstOrDefault();

            if (foundHotel != null)
            {
                viewModel = new HotelViewModel()
                {
                    HotelId          = foundHotel.HotelId,
                    HotelName        = foundHotel.HotelName,
                    HotelDescription = foundHotel.HotelDescription,
                    CountryId        = foundHotel.CountryId,
                    StarRating       = foundHotel.StarRating,
                    HotelCode        = foundHotel.HotelCode,
                    Price            = foundHotel.Price.GetValueOrDefault(),
                    Pool             = foundHotel.Pool,
                    Spa  = foundHotel.Spa,
                    Wifi = foundHotel.Wifi
                };
            }

            ViewData.Model = viewModel;

            if (Request.IsAjaxRequest())
            {
                return(PartialView("CreateHotel"));
            }
            else
            {
                return(View("CreateHotel"));
            }
        }
Exemple #18
0
        public IActionResult Hotel(HotelViewModel model, int id)
        {
            var hotel = _hotelManager.Get(id);

            model.Name = hotel.Name;


            var maxDays    = DateTime.DaysInMonth(2017, 2);
            var bookedDays = _daysManager.GetBooked();
            List <CalendarDay> daysInMonth = new List <CalendarDay>();

            model.Rooms = _roomManagerData.GetRoomsForHotel(id);

            //var keyIndex = daysInMonth.FindIndex(i => i.Id == );

            for (int i = 0; i < maxDays; i++)
            {
                //if(day.Number == keyIndex)
                //{
                //    daysInMonth.Add(_daysManager.)
                //}
                daysInMonth.Add(new CalendarDay());
            }
            //model.CalendarDays = daysInMonth;

            return(View(model));
        }
Exemple #19
0
        public IActionResult AddHotel(HotelViewModel model, int id)
        {
            string userId = _userManagerData.GetLoggedUserId();
            var    user   = _userManagerData.Get(userId);
            var    hotel  = _hotelManager.Get(id);

            if (hotel.OwnerId == null)
            {
                hotel.OwnerId = userId;
                hotel.Name    = model.Name;
                _hotelManager.Commit();
                return(RedirectToAction("Dashboard"));
            }
            else
            {
                var newhotel = new Hotel();

                newhotel.Name    = model.Name;
                newhotel.Status  = 1;
                newhotel.OwnerId = userId;

                _hotelManager.Add(newhotel);
                _hotelManager.Commit();

                return(RedirectToAction("Dashboard"));
            }
        }
        public async Task <IActionResult> EditHotel(HotelViewModel editHotel, long hotelId)
        {
            if (ModelState.IsValid)
            {
                await hotelService.EditHotelAsync(hotelId, editHotel);

                if (editHotel.Files != null)
                {
                    var errors = imageService.Validate(editHotel.Files, editHotel);
                    if (errors.Count != 0)
                    {
                        ViewBag.TimeZones = dateTimeService.FindTimeZones();
                        return(View(editHotel));
                    }

                    await imageService.UploadAsync(editHotel.Files, hotelId);

                    await hotelService.SetIndexImageAsync(hotelId);
                }

                await hotelPropertyTypeService.EditPropertyTypeAsync(hotelId, editHotel.PropertyType);

                return(RedirectToAction(nameof(HotelController.HotelInfo), "Hotel", new { hotelId }));
            }
            ViewBag.TimeZones = dateTimeService.FindTimeZones();
            return(View(editHotel));
        }
        public async Task <IActionResult> AddHotel(HotelViewModel newHotel)
        {
            if (ModelState.IsValid)
            {
                var currentUser = await userManager.GetUserAsync(HttpContext.User);

                var hotelId = await hotelService.AddHotelAsync(newHotel, currentUser.Id);

                if (newHotel.Files != null)
                {
                    var errors = imageService.Validate(newHotel.Files, newHotel);
                    if (errors.Count != 0)
                    {
                        ViewBag.TimeZones = dateTimeService.FindTimeZones();
                        return(View(newHotel));
                    }

                    await imageService.UploadAsync(newHotel.Files, hotelId);

                    await hotelService.SetIndexImageAsync(hotelId);
                }

                return(RedirectToAction(nameof(HotelController.HotelInfo), "Hotel", new { hotelId }));
            }
            ViewBag.TimeZones = dateTimeService.FindTimeZones();
            return(View(newHotel));
        }
Exemple #22
0
        public async Task <ActionResult> RegistrarHotel(HotelViewModel model)
        {
            if (ModelState.IsValid)
            {
                Hotel hotel = new Hotel()
                {
                    Id          = Guid.NewGuid(),
                    Nombre      = model.Nombre,
                    Descripcion = model.Descripcion,
                    CupoMaximo  = model.CupoMaximo,
                    TipoHotelId = model.TipoHotelId,
                    CiudadId    = model.CiudadId,
                    CreateBy    = User.Identity.Name,
                    CreateTime  = DateTime.Now
                };

                var resultado = await _hotelService.RegistrarHotel(hotel);

                if (resultado)
                {
                    TempData["mensaje"] = $"Se Registro Correctamente el hotel {model.Nombre}";
                }
                else
                {
                    TempData["mensaje"] = $"Ocurrio un problema al tratar de registrar el hotel {model.Nombre}";
                }
                return(RedirectToAction("Index"));
            }
            return(View());
        }
        public ActionResult Update([Bind(Exclude = "RoomCategory")] HotelViewModel hotelViewModel)
        {
            Hotel hotel = AutoMapper.Mapper.Map <HotelViewModel, Hotel>(hotelViewModel);

            hotelDetails.UpdateHotel(hotel);
            return(RedirectToAction("ManageHotel", "HotelDetails"));
        }
Exemple #24
0
        public IActionResult CheckinAdd(int id)
        {
            var roomnumbertocheckin = from n in _context.Reserevations
                                      where n.ReservationID == id
                                      select n.RoomID;
            var roomtocheckin = from m in _context.Rooms
                                where m.RoomID == roomnumbertocheckin.First()
                                select m;
            var usertocheckin = from n in _context.Reserevations
                                where n.ReservationID == id
                                select n.GuestName;

            roomtocheckin.First().is_ocuppied = true;
            roomtocheckin.First().Guest       = usertocheckin.First();
            _context.SaveChanges();
            //return RedirectToAction(nameof(Index));
            ViewBag.CheckinInformation = "Check-in complete.";
            ViewBag.CheckinData        = $"Room nr {roomtocheckin.First().RoomID} has been rented to {usertocheckin.First()}.";
            var roomreservedfortoday = from o in _context.Reserevations
                                       where o.check_in == DateTime.Today
                                       select o;
            var roomnotoccupiedtoday = from m in _context.Rooms
                                       where m.is_ocuppied == false
                                       select m;
            var checkindata = new HotelViewModel
            {
                ReservedForToday = roomreservedfortoday.ToList(),
                RoomList         = roomnotoccupiedtoday.ToList()
            };

            return(View(checkindata));
        }
Exemple #25
0
        public JsonHotel HotelList()
        {
            JsonHotel             jsonHotel        = new JsonHotel();
            HotelViewModel        Hotellistobj     = new HotelViewModel();
            List <HotelViewModel> hotellinklistobj = new List <HotelViewModel>();

            try
            {
                var listHotell = _place.PlaceHotellList();
                foreach (var item in listHotell)
                {
                    Hotellistobj.Name        = item.Name;
                    Hotellistobj.Address     = _address.FindById(item.AdressId).Detail;
                    Hotellistobj.CategoryId  = item.CategoryId;
                    Hotellistobj.DetailId    = item.DetailId;
                    Hotellistobj.Cost        = item.Cost;
                    Hotellistobj.LocationX   = _address.FindById(item.AdressId).LocationX;
                    Hotellistobj.LocationY   = _address.FindById(item.AdressId).LocationY;
                    Hotellistobj.LocationR   = _address.FindById(item.AdressId).LocationR;
                    Hotellistobj.PhoneNumber = item.PhoneNumber;
                    hotellinklistobj.Add(Hotellistobj);
                }
                jsonHotel.result = hotellinklistobj;
                return(jsonHotel);
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                return(jsonHotel);
            }
        }
        public ActionResult EditHotel(HotelViewModel hotelViewModel)
        {
            Hotel hotel     = AutoMapper.Mapper.Map <HotelViewModel, Hotel>(hotelViewModel);
            Hotel hotelView = hotelDetails.GetHotelDetailsById(hotel.HotelId);

            return(View(hotelView));
        }
Exemple #27
0
        public ActionResult CreateHotel(HotelViewModel hotelView, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid & Image != null)
            {
                byte[] imageData = null;
                using (var binaryReader = new BinaryReader(Image.InputStream))
                {
                    imageData = binaryReader.ReadBytes(Image.ContentLength);
                }
                var Hotel = new Hotels
                {
                    Id          = Guid.NewGuid().ToString(),
                    Name        = hotelView.Name,
                    Adress      = hotelView.Address,
                    City        = hotelView.City,
                    PhoneNumber = hotelView.PhoneNumber,
                    WebSite     = hotelView.WebSite,
                    Rooms       = new List <Rooms>(),
                    ImageData   = imageData,
                    Description = hotelView.Description,
                    CountStar   = hotelView.CountStar
                };
                db.Hotels.Add(Hotel);

                db.SaveChanges();
                TempData["Message"] = "Отель успешно добавлен.";
                return(RedirectToAction("Index", "Admin"));
                // return PartialView("Success");
            }
            //TempData["Message"] = "Ошибка добавления.";
            //return RedirectToAction("Index", "Admin");
            return(PartialView(hotelView));
        }
Exemple #28
0
        public ActionResult Save(Hotel hotel)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new HotelViewModel()
                {
                    Hotel     = hotel,
                    Countries = _context.Countries.ToList()
                };

                return(View("Form", viewModel));
            }

            if (hotel.Id == 0)
            {
                _context.Hotels.Add(hotel);
            }
            else
            {
                var hotelInDb = _context.Hotels.Single(c => c.Id == hotel.Id);
                hotelInDb.Name           = hotel.Name;
                hotelInDb.City           = hotel.City;
                hotelInDb.CountryId      = hotel.CountryId;
                hotelInDb.IsAllInclusive = hotel.IsAllInclusive;
                hotelInDb.PricePerNight  = hotel.PricePerNight;
                hotelInDb.Stars          = hotel.Stars;
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "Hotels"));
        }
        public async Task <IActionResult> Edit(HotelViewModel hotelVM)
        {
            var isAuthorize = await _authorizationService.AuthorizeAsync(User, hotelVM.Hotel, HotelOperations.Update);

            if (!isAuthorize.Succeeded)
            {
                return(Forbid());
            }

            if (hotelVM.ChangeImageUrl == null)
            {
                hotelVM.Hotel.ImageUrl = hotelVM.ImageUrlDisplay;
                await _hotelService.UpdateHotel(hotelVM.Hotel.HotelID, hotelVM.Hotel);

                return(RedirectToAction("Index"));
            }
            else
            {
                hotelVM.Hotel.ImageUrl = hotelVM.ChangeImageUrl.FileName;
                await _hotelService.UpdateHotel(hotelVM.Hotel.HotelID, hotelVM.Hotel);
                await UploadFileImg(hotelVM.ChangeImageUrl);

                return(RedirectToAction("Index"));
            }
        }
        public async Task <IActionResult> Edit(string id, [Bind("HotelId,HotelName,Destinatino,Contact,MinPPP,MaxPPP")] HotelViewModel hotelViewModel)
        {
            if (id != hotelViewModel.HotelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hotelViewModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HotelViewModelExists(hotelViewModel.HotelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotelViewModel));
        }
        public ActionResult HotelsByCity(int countryId, string city)
        {
            var hotelList = GetHotels();
            var hotelsBycountry = hotelList.Where(hl => hl.CountryId == countryId && hl.City == city);

            var hotelViewModel = new HotelViewModel();
            Hotel selectedHotel = hotelsBycountry.Take(1).SingleOrDefault();
            hotelViewModel.SelectedCountry = selectedHotel.City + ", " + selectedHotel.CountryName;
            hotelViewModel.Data = hotelsBycountry;
            return View("Hotels", hotelViewModel);
        }
        public ActionResult Hotels(int countryId)
        {
            var hotelList = GetHotels();
            var hotelsBycountry = hotelList.Where(hl => hl.CountryId == countryId);

            var hotelViewModel = new HotelViewModel();
            Hotel selectedHotel = hotelsBycountry.Take(1).SingleOrDefault();
            hotelViewModel.SelectedCountry = selectedHotel.CountryName;
            hotelViewModel.Data = hotelsBycountry;
            return View(hotelViewModel);
        }
 public ActionResult AddHotel()
 {
     var model = new HotelViewModel { Cities = this.GetCities() };
     return this.View(model);
 }
 public ActionResult AddHotel(HotelViewModel model)
 {
     if (this.ModelState.IsValid)
     {
         try
         {
             //model.City = this.cityService.GetCity(model.CityId);
             Mapper.CreateMap<HotelViewModel, HotelDto>();
             var hotel = Mapper.Map<HotelDto>(model);
             this.hotelService.CreateHotel(hotel);
             this.hotelService.Commit();
         }
         catch (Exception exception)
         {
             this.ViewData["ErrMsg"] = exception.Message;
             this.ViewData["ErrTrace"] = exception.StackTrace;
             return this.View("Error", new { area = "" });
         }
     }
     model = new HotelViewModel { Cities = this.GetCities() };
     return this.View(model);
 }