Inheritance: System.Web.UI.Page
Ejemplo n.º 1
0
        public ActionResult Insert(Hotels hotels)
        {
            if (ModelState.IsValid)
            {
                db.Hotels.Add(hotels);
                db.SaveChanges();

                hotelsModel.HotelsList = db.Hotels.ToList();
                hotelsModel.SelectedHotel = db.Hotels.Find(hotels.HotelID);
//                hotelsModel.DisplayMode = "displayHotel";             
            }
            return View("Index", hotelsModel);
        }
        // POST api/HotelsAPI
        public HttpResponseMessage PostHotels(Hotels hotels)
        {
            if (ModelState.IsValid)
            {
                db.Hotels.Add(hotels);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, hotels);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = hotels.HotelID }));
                return response;
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
Ejemplo n.º 3
0
        public static OutgoingDetailedHotel Parse(Hotels x)
        {
            if (x == null)
            {
                return(null);
            }

            return(new OutgoingDetailedHotel
            {
                Id = x.Id,
                Name = x.Name,
                Address = x.Address,
                TaxRate = x.TaxRate,
                IsHidden = x.IsHidden
            });
        }
Ejemplo n.º 4
0
        protected override void OnInit(EventArgs e)
        {
            if (!Request.IsLocal && !Request.IsSecureConnection)
            {
                string redirectUrl = Request.Url.ToString().Replace("http:", "https:");
                Response.Redirect(redirectUrl, false);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
            if (Context.Session != null)
            {
                string sessionUser  = Session["CurrentUser"] != null ? Session["CurrentUser"].ToString() : string.Empty;
                string sessionHotel = Session["Hotel"] != null ? Session["Hotel"].ToString() : string.Empty;
                int    hotelId;

                if (!string.IsNullOrEmpty(sessionUser))
                {
                    PublicCustomerInfos = JsonConvert.DeserializeObject <CustomerInfos>(sessionUser);
                }

                if (!string.IsNullOrEmpty(sessionHotel) && !Request.Url.AbsoluteUri.Contains(Constant.HotelList))
                {
                    hotelId     = JsonConvert.DeserializeObject <int>(sessionHotel);
                    PublicHotel = _hotelRepository.GetById(hotelId);
                }

                if (Request.Params["hotelId"] != null)
                {
                    int.TryParse(Request.Params["hotelId"], out hotelId);
                    PublicHotel = _hotelRepository.GetHotel(hotelId, PublicCustomerInfos != null ? PublicCustomerInfos.EmailAddress : string.Empty);
                    if (PublicHotel != null)
                    {
                        Session["Hotel"] = PublicHotel.HotelId;
                    }
                }
            }

            if (PublicCustomerInfos == null || !PublicCustomerInfos.IsActive)
            {
                Response.Redirect(string.Format(Constant.SignIpPageAdmin, HttpUtility.UrlEncode(Request.Url.PathAndQuery)));
            }

            if (PublicHotel == null || (PublicCustomerInfos != null && PublicCustomerInfos.IsCheckInOnly && !Request.Url.AbsoluteUri.Contains("BookingPage.aspx")))
            {
                Response.Redirect(string.Format(Constant.HotelList));
            }
            base.OnInit(e);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Проверка заполнения обязательных полей и добавление локации в базу данных.
        /// </summary>
        /// <returns>True - если все обязательные поля заполнены и локация добавлена в БД. False - если заполнены не все обязательные поля или возникла ошибка при добавлении данных в БД.</returns>
        private bool AddLocation()
        {
            if (LocationNameTextBox.TextLength > 0 && LocationNameTextBox.Text != LocationNameTextBox.Tag.ToString() &&
                RoomCountTextBox.TextLength > 0 && RoomCountTextBox.Text != RoomCountTextBox.Tag.ToString() &&
                BedsCountTextBox.TextLength > 0 && BedsCountTextBox.Text != BedsCountTextBox.Tag.ToString() &&
                CheckRoomsData())    // Если все обязательные поля заполнены.
            {
                long locationId = Locations.Add(LocationNameTextBox.Text.Trim());
                if (locationId >= 0)
                {
                    long hotelId = Hotels.Add(locationId, Customer.Id, Convert.ToInt32(RoomCountTextBox.Text), Convert.ToInt32(BedsCountTextBox.Text), Convert.ToInt32(CardCountTextBox.Text));
                    if (hotelId >= 0)
                    {
                        for (int i = 0; i < RoomsDataGridView.RowCount; i++)
                        {
                            string roomName  = RoomsDataGridView["RoomNumber", i].Value.ToString().Trim();
                            string bedsCount = RoomsDataGridView["BedsCount", i].Value.ToString().Trim();

                            if (Hotels.FindRoom(roomName, hotelId, out long roomId)) // Если в БД есть такие комнаты.
                            {
                                Hotels.EditRoom(roomId, roomName, Convert.ToInt64(bedsCount));
                            }
                            else
                            {
                                Hotels.AddRoom(hotelId, roomName, Convert.ToInt32(bedsCount));
                            }
                        }

                        LocationsDataGridView.DataSource = Hotels.GetAll(Customer.Id);

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
 public async Task <Hotels> UpdateHotelAsync(Hotels hotel)
 {
     try
     {
         var hotelExist = dbContext.Hotel.FirstOrDefault(p => p.ID == hotel.ID);
         if (hotelExist != null)
         {
             dbContext.Update(hotel);
             await dbContext.SaveChangesAsync();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(hotel);
 }
Ejemplo n.º 7
0
        public ActionResult Hotels_Update(Hotels hotel)
        {
            bool           success = hotelsrepo.Update(hotel);
            HotelViewModel data    = new HotelViewModel();

            data.hotels = hotelsrepo.Read();
            data.rooms  = roomrepo.Read();
            data.types  = typesrepo.Read();
            data.users  = usersrepo.Read();
            if (success)
            {
                ViewBag.Message = "Successfully Updated";
                return(View("Hotels_Read", data));
            }
            ViewBag.Message = "Encountered an Error while updating";
            return(View("Hotels_Read", data));
        }
Ejemplo n.º 8
0
        public IActionResult Buy(int id)
        {
            if (SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, "Book") == null)
            {
                List <Item> book = new List <Item>();
                book.Add(new Item
                {
                    HotelRooms = context.HotelRooms.Find(id),
                    Quantity   = 1
                });

                SessionHelper.SetObjectAsJon(HttpContext.Session, "Book", book);
            }


            else
            {
                List <Item> book = SessionHelper.GetObjectFromJson <List <Item> >
                                       (HttpContext.Session, "Book");
                int index = isExit(id);
                if (index != -1)
                {
                    book[index].Quantity++;
                }

                else
                {
                    book.Add(new Item
                    {
                        HotelRooms = context.HotelRooms.Find(id),
                        Quantity   = 1
                    });
                    SessionHelper.SetObjectAsJon(HttpContext.Session, "Book", book);
                }
            }

            HotelRooms hotelRooms = context.HotelRooms.Where(x => x.RoomId == id).SingleOrDefault();

            ViewBag.HotelRoom = hotelRooms;
            int    hid    = ViewBag.HotelRoom.HotelId;
            Hotels hotels = context.Hotels.Where(x => x.HotelId == id).SingleOrDefault();

            ViewBag.Hotel = hotels;
            return(RedirectToAction("Details", "HotelRoom", new { @id = hid }));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> PutHotel(int id, Hotels hotel)
        {
            if (id != hotel.Id)
            {
                return(BadRequest());
            }

            bool didUpdate = await hotelRepository.UpdateHotel(id, hotel);

            if (!didUpdate)
            {
                return(NotFound());
            }



            return(NoContent());
        }
        public ActionResult Index(string name)
        {
            ViewBag.PageName = "hotel";
            Hotels hotel = _context.Hotels
                           .Include(x => x.Rooms)
                           .FirstOrDefault(hotel => hotel.Slug == name);

            if (hotel == null)
            {
                ViewBag.NotFoundMessage = "Hotel not found";
                Response.StatusCode     = 404;
                return(View("NotFound"));
            }

            ViewBag.Available = hotel.Availability;
            ViewBag.Title     = hotel.Name;
            return(View(hotel));
        }
Ejemplo n.º 11
0
 public Response  GetSpecificHotel(int id)
 {
     for (int i = 0; i < Hotel_list.Count; i++)
     {
         Hotels h = new Hotels();
         if (id == Convert.ToInt32(Hotel_list[h.HotelId]))
         {
             return(new Response()
             {
                 hotel = Hotel_list[i],
                 Status = new Error()
                 {
                     Status = status.Success,
                 }
             });
         }
     }
 }
Ejemplo n.º 12
0
        public LocationInfo()
        {
            InitializeComponent();

            Hotels.FillInfo();

            NameTextBox.Text       = Locations.Name;
            RoomsCountTextBox.Text = Hotels.RoomCount.ToString();
            BedsCountTextBox.Text  = Hotels.BedsCount.ToString();
            CardsCountTextBox.Text = Hotels.CardsCount.ToString();
            DataTable rooms = Hotels.GetRooms();

            for (int i = 0; i < rooms.Rows.Count; i++)
            {
                RoomsDataGridView.Rows.Add(rooms.Rows[i].ItemArray);
            }

            CustomerLocationNameLabel.Text = $"Мои заказчики > {Customer.Name} > {Locations.Name}";
        }
Ejemplo n.º 13
0
        public static OutgoingHotel Parse(Hotels x)
        {
            if (x == null)
            {
                return(null);
            }

            return(new OutgoingHotel
            {
                Id = x.Id,
                Name = x.Name,
                Address = x.Address,
                Latitude = x.Latitude,
                Longitude = x.Longitude,
                TaxRate = x.TaxRate,
                Picture = OutgoingMinimalPicture.Parse(x.Pictures),
                IsHidden = x.IsHidden
            });
        }
Ejemplo n.º 14
0
        public static void Load()
        {
            Load(Hotels, "Hotel");
            Load(Administrators, "Admin");
            Load(Guests, "Guest");
            Load(Rooms, "Room");

            for (int i = 0; i < Administrators.Count; i++)
            {
                int hotelId = Administrators[i].Hotel.Id;
                Administrators[i].Hotel = Hotels.First(x => x.Id == hotelId);
            }

            for (int i = 0; i < Rooms.Count; i++)
            {
                int hotelId = Rooms[i].Hotel.Id;
                Rooms[i].Hotel = Hotels.First(x => x.Id == hotelId);
            }
        }
        private void listHotels_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            hotel = (Hotels)listHotels.SelectedItem;
            grdHotelInfo.DataContext = hotel;

            try
            {
                hotel = (Hotels)listHotels.SelectedItem;
                listRooms.ItemsSource = db.Rooms.Where(x => x.HotelsID == hotel.Id).Select(r => new
                {
                    HotelName = r.Hotels.Name,
                    Number    = r.Number,
                    Count     = r.Count,
                    Price     = r.Price,
                    IsBlock   = r.IsBlocked == true ? "Зайнятий" : "Вільний"
                }).ToList();
            }
            catch { }
        }
Ejemplo n.º 16
0
        public ActionResult Hotels_Insert(Hotels hotel)
        {
            hotel.UserId = Convert.ToInt32(Session["userId"]);
            int success = hotelsrepo.Insert(hotel);

            if (success >= 1)
            {
                Room data = new Room();
                data.HotelId = hotel.HotelId;
                for (int i = 0; i < hotel.Rooms; i++)
                {
                    success = roomrepo.Insert(data);
                }
                ViewBag.Message = "Entry Created Successfully";
                return(View("Dashboard"));
            }
            ViewBag.Message = "An error occurred while making the Entry";
            return(View("Dashboard"));
        }
Ejemplo n.º 17
0
        public IActionResult OnPost(string ville, string localisation, DateTime dtDepart, int nbJoursValue, int nbPersonnesValue, int budgetStartValue, int budgetEndValue, string listeActivites)
        {
            ViewData["listeActivites"] = listeActivites;
            ViewData["minBudget"]      = budgetStartValue;
            ViewData["maxBudget"]      = budgetEndValue;
            ViewData["budgetMoyen"]    = ((budgetEndValue - budgetStartValue) / 2) + budgetStartValue;
            Flag = Url.Content(string.Format("~/images/flag/ma.png"));

            Images = new List <string>();
            for (int i = 1; i < 11; i++)
            {
                Images.Add(Url.Content(string.Format("~/images/villes/" + ville.ToLower() + "/" + i.ToString() + ".jpg")));
            }

            var budgetMin = (budgetStartValue * 1.0) / nbJoursValue;
            var budgetMax = (budgetEndValue * 1.0) / nbJoursValue;

            var budgetHotel = (budgetMax * 50) / 100;

            ViewData["budgetHotel"] = budgetHotel;
            var budgetFoods = (budgetMax * 25) / 100;

            ViewData["budgetFoods"] = budgetFoods;
            var budgetActivities = (budgetMax * 25) / 100;


            Hotels           = _context.Hotels.Where(h => (double)h.Prix / 10 <= budgetHotel).OrderBy(h => h.Id).Take(12).ToList();
            Activities       = _context.Activities.Where(a => listeActivites.Contains(a.ImgInteret)).GroupBy(a => a.Nom).Select(a => a.First()).OrderBy(a => a.Id).Take(12).ToList();
            Restaurants      = _context.Restaurants.Take(12).ToList();
            LocationVacances = _context.LocationVacance.Take(12).ToList();

            ViewData["locationRestaurants"] = Restaurants.Where(r => r.Adresse != null).Select(r => r.Adresse).ToArray();
            ViewData["locationHotels"]      = Hotels.Where(r => r.Adresse != null).Select(r => r.Adresse).ToArray();
            ViewData["locationActivities"]  = Activities.Where(r => r.Adresse != null).Select(r => r.Adresse).ToArray();


            ViewData["aPartirH"] = 0;
            ViewData["aPartirR"] = 0;
            ViewData["aPartirA"] = 12;
            return(Page());
        }
Ejemplo n.º 18
0
        private async void BindProperties(Vouchers voucher)
        {
            if (voucher != null)
            {
                Voucher = voucher;
            }

            Clients = await GetClients();

            Hotels = await GetHotels();

            RestTypes = await GetRestTypes();

            AdditionalServices = await GetAdditionalServices();

            Stuffs = await GetStuffs();

            PaymentStatuses = new List <string> {
                "Оплачено", "Не оплачено"
            };
            BookingStatuses = new List <string> {
                "Забронирован", "Не забронирован"
            };

            if (_handleType == HandleType.Add)
            {
                return;
            }
            Client        = Clients.FirstOrDefault(p => Voucher.ClientId == p.Id);
            Hotel         = Hotels.FirstOrDefault(p => Voucher.HotelId == p.Id);
            RestType      = RestTypes.FirstOrDefault(p => Voucher.RestTypeId == p.Id);
            Stuff         = Stuffs.FirstOrDefault(p => Voucher.StuffId == p.Id);
            PaymentStatus = Voucher.PaymentStatus;
            BookingStatus = Voucher.BookingStatus;
            StartDate     = Voucher.StartDate;
            EndDate       = Voucher.EndDate;

            AdditionalService1 = AdditionalServices.FirstOrDefault(p => Voucher.AdditService1Id == p.Id);
            AdditionalService2 = AdditionalServices.FirstOrDefault(p => Voucher.AdditService2Id == p.Id);
            AdditionalService3 = AdditionalServices.FirstOrDefault(p => Voucher.AdditService3Id == p.Id);
        }
Ejemplo n.º 19
0
        public ActionResult Update(Hotels hotels)
        {
            if (ModelState.IsValid)
            {
                Hotels currentHotel = db.Hotels.Find(hotels.HotelID);
                currentHotel.hotel_name = hotels.hotel_name;
                currentHotel.hotel_latitude = hotels.hotel_latitude;
                currentHotel.hotel_longitude = hotels.hotel_longitude;
                currentHotel.address = hotels.address;
                currentHotel.phone = hotels.phone;
                currentHotel.category = hotels.category;
                currentHotel.lowest_rate = hotels.lowest_rate;
                currentHotel.hotel_description = hotels.hotel_description;
                db.SaveChanges();

                hotelsModel.HotelsList = db.Hotels.ToList();
                hotelsModel.SelectedHotel = currentHotel;
                //hotelsModel.DisplayMode = "displayHotel";
            }
            return View("Index", hotelsModel);
        }
Ejemplo n.º 20
0
        public string Put(string id, [FromBody] Hotels value)
        {
            try
            {
                Hotels hotel = dbContext.Hotels.Where(hotel => hotel.Id.Equals(id)).First();

                hotel.Id      = value.Id;
                hotel.Title   = value.Title;
                hotel.City    = value.City;
                hotel.Address = value.Address;

                dbContext.Update(hotel);
                dbContext.SaveChanges();

                return(JsonConvert.SerializeObject("Hotel updated"));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(ex.InnerException.Message));
            }
        }
        private void InitHotels()
        {
            List <string> existingHotels = new List <string>();
            string        sql            = $"SELECT DISTINCT hotel_code FROM include WHERE pass_number = {StationManager.SelectedPass.PassNumber}";
            MySqlCommand  comand         = new MySqlCommand(sql, ConnectionManager.Connection);

            using (MySqlDataReader reader = comand.ExecuteReader())
            {
                while (reader.Read())
                {
                    existingHotels.Add(reader.GetString(0));
                }
            }
            foreach (Hotel hotel in StationManager.DataStorage.GetHotels())
            {
                if (!existingHotels.Contains(hotel.HotelCode))
                {
                    Hotels.Add(hotel);
                }
            }
        }
        // PUT api/HotelsAPI/5
        public HttpResponseMessage PutHotels(int id, Hotels hotels)
        {
            if (ModelState.IsValid && id == hotels.HotelID)
            {
                db.Entry(hotels).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
        public ActionResult Create([Bind(Include = "IdPromo,IdHotel,DateDebut,DateFin,Valeur")] Promotions promotions)
        {
            if (ModelState.IsValid)
            {
                Hotels hotels = db.Hotels.Find(promotions.IdHotel);
                try
                {
                    hotels.ajouterPromotion(db, promotions);
                }
                catch (Exception)
                {
                    ViewBag.IdHotel       = new SelectList(db.Hotels, "IdHotel", "Nom");
                    ViewBag.MessageErreur = "Impossible d'ajouter cette promotion car elle chevauche une promotion existante.";
                    return(View(promotions));
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IdHotel = new SelectList(db.Hotels, "IdHotel", "Nom", promotions.IdHotel);
            return(View(promotions));
        }
Ejemplo n.º 24
0
        public async Task <HttpResponseMessage> GetProductDetailsBy_SuppName_SupHtlId(string spname, string id)
        {
            _database = MongoDBHandler.mDatabase();
            var accomodationsList  = _database.GetCollection <HotelsHotel>("Accommodations");
            var productMappingList = _database.GetCollection <ProductMapping>("ProductMapping");

            //FilterDefinition<HotelsHotel> filterAcco;
            //FilterDefinition<ProductMapping> filterPM;
            var idList = id.Split(',');

            XDocument doc = new XDocument();

            doc.Add(new XElement("Hotels"));

            Hotels             _Hotels      = new Hotels();
            List <HotelsHotel> _HotelsHotel = new List <HotelsHotel>();

            foreach (var hotelId in idList)
            {
                var searchResultPM = await productMappingList.Find(x => (x.SupplierCode.ToLower() == spname.ToLower() && x.SupplierProductCode.ToLower() == hotelId.ToLower())).ToListAsync();

                foreach (var resultPM in searchResultPM)
                {
                    var searchResultAcco = await accomodationsList.Find(x => (x.HotelId.ToLower() == resultPM.SystemProductCode.ToLower())).ToListAsync();

                    foreach (var hotel in searchResultAcco)
                    {
                        hotel.SupplierHotelID = hotelId;
                        _HotelsHotel.Add(hotel);
                    }
                }
            }

            _Hotels.Hotel = _HotelsHotel;

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, _Hotels);

            return(response);
        }
        public ActionResult HotelDelete(int id)
        {
            GDbContext db = new GDbContext(); // Establish connection to database

            // Retrieve hotel from database
            Hotels hotel = db.Hotel.SingleOrDefault(h => h.HOTEL_ID == id) as Hotels;

            if (hotel == null) // Return error if hotel isn't found
            {
                return(HttpNotFound());
            }

            if (ModelState.IsValid)                     // Check for valid ModelState
            {
                hotel.DELETE_STAT = !hotel.DELETE_STAT; // Soft delete or undelete based on current status
                db.SaveChanges();                       // Save changes to datebase

                return(RedirectToAction("HotelList"));  // Return to hotel list
            }

            return(View(hotel)); // Returns view, should not occur
        }
        public async Task <bool> UpdateHotel(int id, Hotels hotel)
        {
            _context.Entry(hotel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HotelExists(id))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }
        }
Ejemplo n.º 27
0
        public List <InfoOrder> GetGridInfo(List <OrdersToReservations> ordersList)
        {
            List <InfoOrder> infoOrders = new List <Hotel_Project.Model.InfoOrder>();
            Hotels           hotel      = new Hotels();
            Rooms            room       = new Rooms();

            for (int i = 0; i < ordersList.Count; i++)
            {
                try
                {
                    room  = (Rooms)db.Rooms.Find(ordersList[i].RoomID);
                    hotel = (Hotels)db.Hotels.Find(room.HotelsID);
                    InfoOrder ord = new InfoOrder();
                    ord.HotelName    = hotel.Name;
                    ord.RoomNum      = room.Number;
                    ord.DateStartOrd = ordersList[i].DateStart;
                    ord.DateEndOrd   = ordersList[i].DateEnd;
                    infoOrders.Add(ord);
                }
                catch (Exception ex) { }
            }
            return(infoOrders);
        }
Ejemplo n.º 28
0
        public override void FiltrByBedNumber()
        {
            if (BedNumber > 0)
            {
                if (Resorts != null)
                {
                    List <HolidayHome> list       = Resorts.SelectMany(r => r.HolidayHomes).Where(h => h.numberofBeds == BedNumber).ToList();
                    List <Resort>      listresort = list.Select(l => l.Resort).ToList();
                    Resorts = listresort.AsEnumerable <Resort>().Distinct().ToList();
                    List <Room>   listroom    = Resorts.SelectMany(r => r.Rooms).Where(h => h.numberofBeds == BedNumber).ToList();
                    List <Resort> listresort2 = list.Select(l => l.Resort).ToList();
                    Resorts.AddRange(listresort2);
                    Resorts = Resorts.AsEnumerable <Resort>().Distinct().ToList();
                }

                if (Hotels != null)
                {
                    List <Room>  list      = Hotels.SelectMany(r => r.Rooms).Where(h => h.numberofBeds == BedNumber).ToList();
                    List <Hotel> listhotel = list.Select(l => l.Hotel).ToList();
                    Hotels = listhotel.AsEnumerable <Hotel>().Distinct().ToList();
                }
            }
        }
        public List <Hotels> GetHotels(string connectionName)
        {
            Database  db        = DatabaseFactory.CreateDatabase(connectionName);
            DbCommand dbCommand = db.GetStoredProcCommand(Resources.HotelResources.SP_GetHotels);

            List <Hotels> hotelsList = new List <Hotels>();

            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                int _id        = dr.GetOrdinal(Resources.HotelResources.PARAM_HOTELID);
                int _namechain = dr.GetOrdinal(Resources.HotelResources.PARAM_HOTELNAMECHAIN);

                while (dr.Read())
                {
                    Hotels item = new Hotels();
                    item.HotelID        = dr.GetString(_id);
                    item.HotelNameChain = (dr[_namechain] == null) ? Types.StringNullValue : dr.GetString(_namechain);
                    hotelsList.Add(item);
                }
            }

            return(hotelsList);
        }
Ejemplo n.º 30
0
        public HotelDetailsViewModel(Hotels selectedHotel, HandleType handleType)
        {
            _handleType = handleType;
            switch (handleType)
            {
            case HandleType.Add:
                ChangeBtnVisibility = Visibility.Collapsed;
                LabelVisibility     = Visibility.Collapsed;
                break;

            case HandleType.Change:
                ChangeBtnVisibility = Visibility.Collapsed;
                LabelVisibility     = Visibility.Collapsed;
                BindProperties(selectedHotel);
                break;

            case HandleType.View:
                ChangeBtnVisibility = Visibility.Visible;
                LabelVisibility     = Visibility.Visible;
                BindProperties(selectedHotel);
                break;
            }
        }
Ejemplo n.º 31
0
        public async Task <Result <Hotels> > GetHotelsCall(Query request)
        {
            Hotels hotelsList = new Hotels();

            try
            {
                AmadeusToken token = await _tokenService.GetToken();

                _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);
                using (var response = await _httpClient.GetAsync(_config.GetConnectionString("AmadeusAPIUrl") + request.param.ToQueryString()))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    hotelsList = JsonConvert.DeserializeObject <Hotels>(apiResponse);
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error getting data from Amadeus API", e.Message);
                throw e;
            }

            return(Result <Hotels> .Success(hotelsList));
        }
Ejemplo n.º 32
0
        public Response SearchHotelById(int id)
        {
            Hotels h1 = new Hotels();



            var HotelObj = Hotel_list.Find((p) => p.HotelId == id);

            if (HotelObj != null)
            {
                return(new Response
                {
                    hotel = HotelObj,
                    status = new Status()
                    {
                        RespMessage = "Success",
                        ErrorCode = 200,
                    }
                });
            }



            else
            {
                return(new Response
                {
                    hotel = null,
                    status = new Status()
                    {
                        RespMessage = "Hotel Of Specified Id  does not exists.",
                        ErrorCode = 404,
                    }
                });
            }
        }
Ejemplo n.º 33
0
        // end of code

        public HotelCreateViewModel GetHotelCreateViewModel(Hotels hotels)
        {
            HotelCreateViewModel HotelPass = new HotelCreateViewModel()
            {
                IdHotel          = hotels.IdHotel,
                HotelName        = hotels.HotelName,
                DescriptionTable = hotels.DescriptionTable,
                Stars            = hotels.Stars,
                IdLocation       = hotels.Stars,
                GaleryImages     = context.HotelImages.Where(x => x.IdHotel == hotels.IdHotel).ToArray()
            };

            HotelPass.imagesString = new string[HotelPass.GaleryImages.Length];

            int imageNumber = 0;

            foreach (var item in HotelPass.GaleryImages)
            {
                HotelPass.imagesString[imageNumber] = (Convert.ToBase64String(item.ImageHotel));
                imageNumber++;
            }

            return(HotelPass);
        }
Ejemplo n.º 34
0
        public void Handle(HotelCreated e)
        {
            Hotels.Add(new Hotel
            {
                Id           = e.HotelId,
                TournamentId = e.Id,
                Name         = e.Name,
                Website      = e.Website,
                PhoneNumber  = e.PhoneNumber,
                RoomTypes    = e.RoomTypes
            });

            Storage.Create(new TSHotelLogo
            {
                Id       = e.HotelId,
                Contents = e.Logo
            });

            Storage.Create(new TSHotelImage
            {
                Id       = e.HotelId,
                Contents = e.Image
            });
        }