public void AddReservationRooms(int referenceNumber, int[] reservationIDs)
 {
     var hotelService = new HotelService();
     foreach (var reservationID in reservationIDs)
     {
         var reservation = hotelService.GetReservation(reservationID);
         var reservationRoom = new Reservation_Room();
         reservationRoom.reservation_id = reservationID;
         reservationRoom.reference_number = referenceNumber;
         reservationRoom.hotel_code = reservation.hotel_code;
         reservationRoom.checkin_date = reservation.checkin_date.Value;
         reservationRoom.checkout_date = reservation.checkout_date.Value;
         db.Reservation_Rooms.InsertOnSubmit(reservationRoom);
     }
     db.SubmitChanges();
 }
示例#2
0
        public async Task SortByPriceLowToHigh()
        {
            bool               sorted        = false;
            HotelService       _hotelService = new HotelService(new HotelRepository());
            DataSourceRequests req           = new DataSourceRequests
            {
                ApiKey = "TESTASC",
                Sort   = "ASC"
            };

            var result = await _hotelService.FetchAllHotels(req);

            for (int i = 0; i < result.Hotels.Count - 1; i++)
            {
                if (result.Hotels[i].PRICE <= result.Hotels[i + 1].PRICE)
                {
                    sorted = true;
                }
            }

            Assert.IsTrue(sorted);
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string error = ValidateForm();

            if (string.IsNullOrEmpty(error))
            {
                try
                {
                    Hotel hotel = new Hotel();
                    hotel.Ciudad        = (Ciudad)cmbCiudades.SelectedItem;
                    hotel.Direccion     = txtDireccion.Text;
                    hotel.Estrellas     = GetEstrellas();
                    hotel.FechaCreacion = dateTimePicker1.Value;
                    hotel.Mail          = txtMail.Text;
                    hotel.Nombre        = txtNombre.Text;

                    hotel.Regimenes = new List <Regimen>();
                    for (int i = 0; i < chListRegimenes.Items.Count; i++)
                    {
                        if (chListRegimenes.GetItemChecked(i))
                        {
                            Regimen regimen = (Regimen)chListRegimenes.Items[i];
                            hotel.Regimenes.Add(regimen);
                        }
                    }

                    HotelService service = new HotelService();
                    service.Insert(hotel);
                }
                catch (Exception)
                {
                    MessageBox.Show("Ocurrió un error al crear el hotel");
                }
            }
            else
            {
                MessageBox.Show(error);
            }
        }
        public void CanCreateHotel()
        {
            var data = new Hotel
            {
                Name           = "Maidan",
                FoundationYear = 2001,
                Address        = "Praga",
                IsActive       = 1
            };

            var mockSet = new Mock <DbSet <Hotel> >();

            var mockContext = new Mock <ClientDbContext>();

            mockContext.Setup(m => m.Hotels).Returns(mockSet.Object);

            var service = new HotelService(mockContext.Object);

            service.Create(data);

            mockSet.Verify(m => m.Add(It.IsAny <Hotel>()), Times.Once());
        }
示例#5
0
        public async void CanCreateHotel()
        {
            DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("CreateHotel").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                Hotel hotel = new Hotel();
                hotel.ID            = 1;
                hotel.Name          = "test";
                hotel.Phone         = "123-456-7890";
                hotel.Address       = "test address string";
                hotel.NumberOfRooms = 10;

                HotelService hotelService = new HotelService(context);

                await hotelService.CreateHotel(hotel);

                var result = await context.Hotel.FirstOrDefaultAsync(h => h.ID == hotel.ID);

                Assert.Equal(result, hotel);
            }
        }
        public LateCheckOutDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            ConversationState conversationState,
            UserState userState,
            HotelService hotelService,
            IBotTelemetryClient telemetryClient)
            : base(nameof(LateCheckOutDialog), settings, services, responseManager, conversationState, userState, hotelService, telemetryClient)
        {
            var lateCheckOut = new WaterfallStep[]
            {
                HasCheckedOut,
                LateCheckOutPrompt,
                EndDialog
            };

            _hotelService = hotelService;

            AddDialog(new WaterfallDialog(nameof(LateCheckOutDialog), lateCheckOut));
            AddDialog(new ConfirmPrompt(DialogIds.LateCheckOutPrompt, ValidateLateCheckOutAsync));
        }
示例#7
0
        public async void CanGetHotels()
        {
            DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("GetHotels").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                Hotel hotel1 = new Hotel();
                hotel1.ID            = 1;
                hotel1.Name          = "test";
                hotel1.Phone         = "123-456-7890";
                hotel1.Address       = "test address string";
                hotel1.NumberOfRooms = 10;

                Hotel hotel2 = new Hotel();
                hotel2.ID            = 2;
                hotel2.Name          = "test1";
                hotel2.Phone         = "223-456-7890";
                hotel2.Address       = "Test address string";
                hotel2.NumberOfRooms = 3;

                HotelService hotelService = new HotelService(context);

                await hotelService.CreateHotel(hotel1);

                await hotelService.CreateHotel(hotel2);

                var hotelsList = await hotelService.GetHotels();

                var hotels = hotelsList.ToString();

                List <Hotel> resultsList = new List <Hotel>();
                resultsList.Add(hotel1);
                resultsList.Add(hotel2);
                var results = resultsList.ToString();

                Assert.Equal(results, hotels);
            }
        }
        public void AverageRating_ShouldCalculateAverage()
        {
            using (var context = new ApplicationContext(options))
            {
                var hotelService = new HotelService(context, mockPropertyTypeService.Object, mockImageService.Object,
                                                    mockMapper.Object);

                List <Review> reviews = new List <Review>();
                reviews.Add(new Review {
                    Rating = 4
                });
                reviews.Add(new Review {
                    Rating = 2
                });
                reviews.Add(new Review {
                    Rating = 3
                });

                var actual   = hotelService.AverageRating(reviews);
                var expected = 3;
                Assert.Equal(expected, actual);
            }
        }
示例#9
0
        private static void UpdateHotel()
        {
            Console.Clear();
            Console.WriteLine("Indlæs Hotelnr på det hotel du vil ændre");
            int hotelnr = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Indlæs nye Navn på hotellet");
            string navn = Console.ReadLine();

            Console.WriteLine("Indlæs nye Adresse på hotellet");
            string       adresse = Console.ReadLine();
            HotelService hs      = new HotelService();
            bool         ok      = hs.UpdateHotel(new Hotel(hotelnr, navn, adresse), hotelnr);

            if (ok)
            {
                Console.WriteLine("Hotel got updated");
            }
            else
            {
                Console.WriteLine("There was an error in the update");
            }
        }
示例#10
0
        private static void CreateHotel()
        {
            Console.Clear();
            Console.WriteLine("Indlæs Hotelnr");
            int hotelnr = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("indlæs Hotel navn");
            string hotelnavn = Console.ReadLine();

            Console.WriteLine("Indlæs Hotel adresse");
            string       hoteladresse = Console.ReadLine();
            HotelService hs           = new HotelService();
            bool         ok           = hs.CreateHotel((new Hotel(hotelnr, hotelnavn, hoteladresse)));

            if (ok)
            {
                Console.WriteLine("Hotel Created");
            }
            else
            {
                Console.WriteLine("Error occured in creation");
            }
        }
        private async Task <bool> ValidateConfirmExtensionAsync(PromptValidatorContext <bool> promptContext, CancellationToken cancellationToken)
        {
            var convState = await StateAccessor.GetAsync(promptContext.Context, () => new HospitalitySkillState());

            var userState = await UserStateAccessor.GetAsync(promptContext.Context, () => new HospitalityUserSkillState(HotelService));

            if (promptContext.Recognized.Succeeded)
            {
                bool response = promptContext.Recognized.Value;
                if (response)
                {
                    // TODO process requesting reservation extension
                    userState.UserReservation.CheckOutDate = convState.UpdatedReservation.CheckOutDate;

                    // set new checkout date in hotel service
                    HotelService.UpdateReservationDetails(userState.UserReservation);
                }

                return(await Task.FromResult(true));
            }

            return(await Task.FromResult(false));
        }
示例#12
0
        public async Task TryGetAllHotelsInBangkokOnly()
        {
            int                hotelInBangkokCount = 0;
            HotelService       _hotelService       = new HotelService(new HotelRepository());
            DataSourceRequests req = new DataSourceRequests
            {
                ApiKey = "TESTASC",
                Search = "Bangkok",
                Sort   = "ASC"
            };

            var result = await _hotelService.FetchAllHotels(req);

            for (int i = 0; i < result.Hotels.Count; i++)
            {
                if (result.Hotels[i].CITY.Equals("Bangkok"))
                {
                    hotelInBangkokCount++;
                }
            }

            Assert.IsTrue(hotelInBangkokCount == result.TotalRecords);
        }
示例#13
0
        static void Main()
        {
            var locationService = new LocationService();
            var locations = locationService.GetAll();

            var location = locationService.GetById(locations[0].Id);

            var hotelService = new HotelService();
            var hotel = hotelService.GetById(location.Hotels[0].Id);

            var roomService = new RoomService();
            var room = roomService.GetById(hotel.Rooms[0].Id);

            var photoService = new PhotoService();

            // Delete any existing photos
            foreach (var p in room.Photos)
            {
                photoService.Delete(p.Id);
            }

            Console.WriteLine("Adding photo to: {0}", room.Name);

            var photo = new Photo
            {
                Title = "A view of the room", Description = "A beautiful room with wonderful views of the neighbours walls", RoomId = room.Id
            };

            const string roomPhoto = @"Pictures\roomview.jpg";
            const string roomPhoto2 = @"Pictures\roomview_2.jpg";

            photo.Data = ReadPhotoData(roomPhoto);
            photoService.Insert(photo);

            photo.Data = ReadPhotoData(roomPhoto2);
            photoService.Update(photo);
        }
        public void CanGetAllHotels()
        {
            var data = new List <Hotel>
            {
                new Hotel {
                    Name           = "Kyiv",
                    FoundationYear = 1955,
                    Address        = "Chernivtsi",
                    IsActive       = 1
                },
                new Hotel {
                    Name           = "Bukovina",
                    FoundationYear = 1965,
                    Address        = "Kyiv",
                    IsActive       = 1
                },
                new Hotel {
                    Name           = "Maidan",
                    FoundationYear = 2001,
                    Address        = "Praga",
                    IsActive       = 1
                }
            }.AsQueryable();

            var mockSet = new Mock <DbSet <Hotel> >();

            mockSet.As <IQueryable <Hotel> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockHotelContext = new Mock <ClientDbContext>();

            mockHotelContext.Setup(mr => mr.Hotels).Returns(mockSet.Object);

            var service = new HotelService(mockHotelContext.Object);
            var hotels  = service.GetAll();

            Assert.Equal(3, hotels.ToList().Count());
        }
示例#15
0
        private void btnCrear_Click(object sender, EventArgs e)
        {
            string error = ValidateForm();

            if (string.IsNullOrEmpty(error))
            {
                try
                {
                    HotelInhabilitacion hotelInhabilitado = new HotelInhabilitacion();
                    hotelInhabilitado.FechaCreacion = Session.Fecha;
                    hotelInhabilitado.FechaInicio   = dateDesde.Value;
                    hotelInhabilitado.FechaFin      = dateHasta.Value;
                    hotelInhabilitado.Descripcion   = txtDescripcion.Text;
                    hotelInhabilitado.HotelId       = this.hotelId;

                    ReservaService reservaService = new ReservaService();
                    if (reservaService.GetCountActiveReservaBetweenDatesByHotelId(hotelInhabilitado.HotelId, hotelInhabilitado.FechaInicio, hotelInhabilitado.FechaFin) == 0)
                    {
                        HotelService hotelService = new HotelService();
                        hotelService.InsertHotelInhabilitado(hotelInhabilitado);
                        MessageBox.Show("El hotel se ha inhabilitado.");
                    }
                    else
                    {
                        MessageBox.Show("El hotel no puede ser inhabilitado ya que posee reservas en esas fechas");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Ocurrió un error, no se ha podido inhabilitar el hotel.");
                }
            }
            else
            {
                MessageBox.Show(error);
            }
        }
示例#16
0
        static void Main()
        {
            var locationService = new LocationService();
            var locations       = locationService.GetAll();

            var location = locationService.GetById(locations[0].Id);

            var hotelService = new HotelService();
            var hotel        = hotelService.GetById(location.Hotels[0].Id);

            var roomService = new RoomService();
            var room        = roomService.GetById(hotel.Rooms[0].Id);

            var photoService = new PhotoService();

            // Delete any existing photos
            foreach (var p in room.Photos)
            {
                photoService.Delete(p.Id);
            }

            Console.WriteLine("Adding photo to: {0}", room.Name);

            var photo = new Photo
            {
                Title = "A view of the room", Description = "A beautiful room with wonderful views of the neighbours walls", RoomId = room.Id
            };

            const string roomPhoto  = @"Pictures\roomview.jpg";
            const string roomPhoto2 = @"Pictures\roomview_2.jpg";

            photo.Data = ReadPhotoData(roomPhoto);
            photoService.Insert(photo);

            photo.Data = ReadPhotoData(roomPhoto2);
            photoService.Update(photo);
        }
        private async Task <DialogTurnResult> ShowMenuCard(WaterfallStepContext sc, CancellationToken cancellationToken)
        {
            var convState = await StateAccessor.GetAsync(sc.Context, () => new HospitalitySkillState());

            if (convState.FoodList.Count == 0)
            {
                Menu menu = HotelService.GetMenu(convState.LuisResult.Entities.Menu[0][0]);

                // get available items for requested menu
                List <Card> menuItems = new List <Card>();
                foreach (var item in menu.Items)
                {
                    var cardName = GetCardName(sc.Context, "MenuItemCard");

                    // workaround for webchat not supporting hidden items on cards
                    if (Channel.GetChannelId(sc.Context) == Channels.Webchat)
                    {
                        cardName += ".1.0";
                    }

                    menuItems.Add(new Card(cardName, item));
                }

                // show menu card
                await sc.Context.SendActivityAsync(ResponseManager.GetCardResponse(null, new Card(GetCardName(sc.Context, "MenuCard"), menu), null, "items", menuItems));

                // prompt for order
                return(await sc.PromptAsync(DialogIds.FoodOrderPrompt, new PromptOptions()
                {
                    Prompt = ResponseManager.GetResponse(RoomServiceResponses.FoodOrder),
                    RetryPrompt = ResponseManager.GetResponse(RoomServiceResponses.RetryFoodOrder)
                }));
            }

            return(await sc.NextAsync());
        }
示例#18
0
        private static void CreateHotel()
        {
            Console.Clear();
            Console.WriteLine("Opret hotel");
            Console.WriteLine("Indlæs hotelnr:");
            int hotelnr = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Indlæs hotel navn:");
            string navn = Console.ReadLine();

            Console.WriteLine("Indlæs hotel adresse:");
            string       adresse = Console.ReadLine();
            HotelService hs      = new HotelService();
            bool         ok      = hs.CreateHotel(new Hotel(hotelnr, navn, adresse));

            if (ok)
            {
                Console.WriteLine("Hotellet blev oprettet");
            }
            else
            {
                Console.WriteLine("Hotellet blev ikke oprettet");
            }
        }
示例#19
0
        private void DisplayHotels(int currentPage)
        {
            int nrOfHotels;
            int nrOfPages;

            var countyId = (int)countyComboBox.SelectedValue;
            var cityId   = (int)cityComboBox.SelectedValue;

            FilterType filterType = new FilterType(countyId, cityId);

            double       offset       = PageAction.CalculateOffset(currentPage, PAGE_LIMIT);
            List <Hotel> listOfHotels = HotelService.GetListByOffsetAndFilterType(PAGE_LIMIT, offset, filterType);

            if (listOfHotels.Count > 0)
            {
                InitializeDataGridView(listOfHotels);
                nrOfHotels = HotelService.GetTotalNrOfHotels(filterType);
                nrOfPages  = Convert.ToInt32(PageAction.GetNrOfPages(nrOfHotels, PAGE_LIMIT));

                SetPageNr(currentPage);
                //si butoanele disabled unde le faci? care butoane?
                SetEnabledButtons(currentPage, nrOfPages);
            }
        }
        public RequestItemDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            ConversationState conversationState,
            UserState userState,
            HotelService hotelService,
            IBotTelemetryClient telemetryClient)
            : base(nameof(RequestItemDialog), settings, services, responseManager, conversationState, userState, hotelService, telemetryClient)
        {
            var requestItem = new WaterfallStep[]
            {
                HasCheckedOut,
                ItemPrompt,
                ItemRequest,
                EndDialog
            };

            _hotelService = hotelService;

            AddDialog(new WaterfallDialog(nameof(RequestItemDialog), requestItem));
            AddDialog(new TextPrompt(DialogIds.ItemPrompt, ValidateItemPrompt));
            AddDialog(new ConfirmPrompt(DialogIds.GuestServicesPrompt, ValidateGuestServicesPrompt));
        }
        public void Get_Fidelity_Client_Lowest_Hotel_Price_With_1_Day_Test()
        {
            // Arrange
            var input = new RequestLowestPriceDto(
                (int)ClientTypeEnum.Fidelity,
                new List <DateTime>(new DateTime[] {
                new DateTime(2020, 03, 26),//Thur
            })
                );
            var expected = "Parque das flores";

            this._hotelRepository
            .Setup(x => x.GetHotels())
            .Returns(SelectAllFromHotel());

            // Act
            var hotelTest = new HotelService(this._hotelRepository.Object);
            var result    = hotelTest.GetLowestPriceHotel(input);

            // Assert
            Assert.Equal(expected, result.HotelName);

            this._mocker.VerifyAll();
        }
示例#22
0
        async void VerifyCheckinDetail()
        {
            IDashboardService service = new DashboardService();
            int response = await service.UpdateLoginIpAsync(Helper.Helper.QrCertificateKey, new Models.UpdateLoginIP()
            {
                ip = Helper.Helper.IpFromURL
            });

            IHotelService hotelService = new HotelService();

            Models.HotelCheckInResponse hotelResponse = await hotelService.VerifyCheckinDetailAsync(new Models.HotelCheckInRequest()
            {
                Id          = Helper.Helper.HotelCheckinId,
                Certificate = Helper.Helper.QrCertificateKey
            });

            if (hotelResponse != null)
            {
                if (hotelResponse.UserId.Equals(Helper.Helper.UserId))
                {
                    Helper.Helper.IsHotelCheckInFromMobileBrowser = true;
                    MainPage = new NavigationPage(new Views.VerifyPasswordPage());
                }
                else
                {
                    ILoginService serviceLogin = new LoginService();
                    await serviceLogin.ClearLoginAsync(Helper.Helper.QrCertificateKey);

                    MainPage = new NavigationPage(new Views.Hotel.HotelCheckInErrorPage());
                }
            }
            else
            {
                MainPage = new NavigationPage(new Views.Hotel.HotelCheckInErrorPage());
            }
        }
示例#23
0
 public RegionController(IRegionRepository regionRepository, AppConfiguration appConfiguration)
 {
     _regionRepository = regionRepository;
     _hotelService     = new HotelService(regionRepository, appConfiguration);
 }
示例#24
0
 public RoomController()
 {
     _roomTypeService        = new RoomTypeService();
     _hotelDefinitionService = new HotelService();
 }
示例#25
0
 public IHttpActionResult HotelSearch(string Search)
 {
     return(Ok(HotelService.SearchHotel(Search)));
 }
示例#26
0
 public IHttpActionResult PopularDate(int HotelNum)
 {
     return(Ok(HotelService.GetHotelsrecommend(HotelNum)));
 }
示例#27
0
 public IHttpActionResult PopularHotel(int HotelNum)
 {
     return(Ok(HotelService.GetHotelsAll(HotelNum)));
 }
示例#28
0
 public ResponseModel Update(HotelService hotelService)
 {
     return _hotelServiceRepository.Update(hotelService);
 }
示例#29
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            string error = ValidateForm();

            if (string.IsNullOrEmpty(error))
            {
                try
                {
                    Hotel hotel = new Hotel();
                    hotel.Id        = this.hotelId;
                    hotel.Ciudad    = (Ciudad)cmbCiudades.SelectedItem;
                    hotel.Direccion = txtDireccion.Text;
                    hotel.Estrellas = GetEstrellas();
                    hotel.Mail      = txtMail.Text;
                    hotel.Nombre    = txtNombre.Text;
                    hotel.Telefono  = txtTelefono.Text;

                    hotel.Regimenes = new List <Regimen>();
                    for (int i = 0; i < chListRegimenes.Items.Count; i++)
                    {
                        if (chListRegimenes.GetItemChecked(i))
                        {
                            Regimen regimen = (Regimen)chListRegimenes.Items[i];
                            hotel.Regimenes.Add(regimen);
                        }
                    }

                    ReservaService reservaService = new ReservaService();
                    List <Regimen> regimenes      = reservaService.GetActiveReservaRegimenesByHotelId(this.hotelId);

                    string message = string.Empty;
                    foreach (Regimen regimen in regimenes)
                    {
                        if (!hotel.Regimenes.Any(x => x.Codigo == regimen.Codigo))
                        {
                            message += "No puede eliminar el regimen " + regimen.Descripcion + System.Environment.NewLine;
                        }
                    }

                    if (!string.IsNullOrEmpty(message))
                    {
                        message += "tiene reservas asignadas.";
                        MessageBox.Show(message);
                    }
                    else
                    {
                        HotelService hotelService = new HotelService();
                        hotelService.Update(hotel);
                        MessageBox.Show("El hotel se ha modificado correctamente");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Ocurrió un error al modificar el hotel");
                }
            }
            else
            {
                MessageBox.Show(error);
            }
        }
示例#30
0
 public HotelReservationsTest()
 {
     _hs = new HotelService();
     _rs = new ReservationService();
 }
示例#31
0
        /// <summary>
        /// 取得当前微信帐号信息
        /// </summary>
        public WX_UserWeixinInfo GetWeiXinCode()
        {
            if (IsWeiXinCode())
            {
                var model = Session["nowweixin"] as WX_UserWeixinInfo;
                if (model != null)
                {
                    return model;
                }
            }
            else
            {
                //int shopid = GetShopId();
                //if (shopid != 0)
                //{
                //    BLL.wx_diancai_shopinfo shopBll = new BLL.wx_diancai_shopinfo();
                //    Model.wx_diancai_shopinfo shop = shopBll.GetModel(shopid);

                //    return new BLL.wx_userweixin().GetModel(shop.wid.Value);
                //}

                int hotelid = GetHotelId();
                if (hotelid != 0)
                {
                    HotelInfo hotel = null;

                    using (var dbContext = new HotelDbContext())
                    {                        
                        hotel = new HotelService(new HotelRepository()).GetModel(hotelid);                        
                    }

                    if (hotel !=null)
                    {
                        return new WXUserService(new WXUserRepository()).GetModel(hotel.wid.Value);
                    }
                    
                }
                Response.Write("<script>parent.location.href='http://" + HttpContext.Current.Request.Url.Authority + "/admin/weixin/myweixinlist.aspx'</script>");
                Response.End();
            }
            return null;
        }
示例#32
0
 public HotelController(LogisticaSinuContext context)
 {
     _hotelService = new HotelService(context);
 }
示例#33
0
        /// <summary>
        /// 获取查询结果
        /// </summary>
        /// <param name="hotelid"></param>
        /// <param name="_strWhere"></param>
        /// <param name="_orderby"></param>
        /// <returns></returns>
        private DataSet GetQueryData()
        {
            var hotelService = new HotelService();
            var bllhotel     = new BLL.wx_hotels_info();
            var hotel        = bllhotel.GetModel(hotelid);


            this.page = MXRequest.GetQueryInt("page", 1);
            //            txtKeywords.Text = this.keywords;
            DataSet ds = gbll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                ds.Tables[0].Columns.Add("isRefund", typeof(System.String));

                ds.Tables[0].Columns.Add("hotelName", typeof(System.String));
                ds.Tables[0].Columns.Add("totalPrice", typeof(System.Decimal));
                ds.Tables[0].Columns.Add("statusName", typeof(System.String));
                ds.Tables[0].Columns.Add("strisRefund", typeof(System.String));

                DataRow dr;

                int count = ds.Tables[0].Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    dr = ds.Tables[0].Rows[i];

                    int id      = dr.Field <int>("id");
                    int hotelId = dr.Field <int>("hotelId");
                    var status  = HotelStatusManager.OrderStatus.GetStatusDict(
                        MyCommFun.Obj2Int(dr["orderStatus"]));
                    dr["payStatusStr"] = "<em  style='width:70px;' class='status " + status.CssClass
                                         + "'>" + status.StatusName + "</em>";
                    dr["statusName"] = status.StatusName;
                    if (status.StatusId == HotelStatusManager.OrderStatus.Refunding.StatusId ||
                        status.StatusId == HotelStatusManager.OrderStatus.Refunded.StatusId)
                    {
                        dr["isRefund"]    = "<em  style='width:70px;' class='status ok'>是</em>";
                        dr["strisRefund"] = "是";
                    }
                    else if (status.StatusId == HotelStatusManager.OrderStatus.Completed.StatusId)
                    {
                        var tuidanDto = hotelService.GetModel(id, hotelId);
                        if (tuidanDto != null)
                        {
                            dr["isRefund"]    = "<em  style='width:70px;' class='status ok'>是</em>";
                            dr["strisRefund"] = "是";
                        }
                        else
                        {
                            dr["isRefund"]    = "<em  style='width:70px;' class='status no'>否</em>";
                            dr["strisRefund"] = "否";
                        }
                    }
                    else
                    {
                        dr["isRefund"]    = "<em  style='width:70px;' class='status no'>否</em>";
                        dr["strisRefund"] = "否";
                    }
                    dr["hotelName"] = hotel.hotelName;
                    //总花费
                    var dateSpan   = dr.Field <DateTime>("leaveTime") - dr.Field <DateTime>("arriveTime");
                    var totalPrice = MyCommFun.Str2Decimal(dr["price"].ToString()) * dr.Field <int>("orderNum") * dateSpan.Days;
                    dr["totalPrice"] = totalPrice;
                }
                ds.AcceptChanges();
            }


            return(ds);
        }
示例#34
0
 public void TestInitialize()
 {
     hotelRepositoryMock = MockRepository.Create <IHotelRepository>();
     hotelService        = new HotelService(hotelRepositoryMock.Object);
 }
        /// <summary>
        /// booking the selected hotel
        /// </summary>
        /// <param name="hotelDetailsResponse"></param>
        /// <param name="hostToken"></param>
        /// <returns></returns>
        internal HotelCreateReservationRsp HotelBook(HotelDetailsRsp hotelDetailsResponse, HotelService.HostToken hostToken)
        {
            HotelCreateReservationReq hotelCreateReservationReq = new HotelCreateReservationReq();
            UniversalService.BillingPointOfSaleInfo billSaleInfo = new UniversalService.BillingPointOfSaleInfo();
            billSaleInfo.OriginApplication = CommonUtility.GetConfigValue(ProjectConstants.APP);

            hotelCreateReservationReq.BillingPointOfSaleInfo = billSaleInfo;
            hotelCreateReservationReq.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);
            hotelCreateReservationReq.TraceId = "Trace";

            //create two booking traveler, phone number, email and address details
            UniversalService.BookingTraveler bookingTravelerOne = new UniversalService.BookingTraveler();
            bookingTravelerOne.Age = "47";
            bookingTravelerOne.DOB = Convert.ToDateTime("1967-11-23");
            bookingTravelerOne.Gender = "F";
            bookingTravelerOne.Nationality = "AU";
            bookingTravelerOne.TravelerType = "ADT";
            bookingTravelerOne.BookingTravelerName = new UniversalService.BookingTravelerName(){
                First = "Charlotte",
                Last = "Greene",
                Prefix = "MRS"
            };
            UniversalService.PhoneNumber phoneNumberOne= new UniversalService.PhoneNumber()
            {
                AreaCode = "08",
                CountryCode = "61",
                Location = "PER",
                Number = "40003000",
                Type = UniversalService.PhoneNumberType.Home
            };

            bookingTravelerOne.PhoneNumber = new UniversalService.PhoneNumber[1];
            bookingTravelerOne.PhoneNumber[0] = phoneNumberOne;



            UniversalService.Email emailOne = new UniversalService.Email()
            {
                EmailID = "*****@*****.**",
                Type = "Home"
            };

            bookingTravelerOne.Email = new UniversalService.Email[1];
            bookingTravelerOne.Email[0] = emailOne;

            UniversalService.typeStructuredAddress addressOne = new UniversalService.typeStructuredAddress()
            {
                AddressName = "Home",
                Street = new[] { "10 Charlie Street" },
                City = "Perth",
                State = new UniversalService.State()
                {
                    Value = "WA"
                },
                PostalCode = "6000",
                Country = "AU"
            };

            bookingTravelerOne.Address = new UniversalService.typeStructuredAddress[1];
            bookingTravelerOne.Address[0] = addressOne;



            UniversalService.BookingTraveler bookineTravelerTwo = new UniversalService.BookingTraveler();
            bookineTravelerTwo.Age = "50";
            bookineTravelerTwo.DOB = Convert.ToDateTime("1970-05-09");
            bookineTravelerTwo.Gender = "M";
            bookineTravelerTwo.Nationality = "AU";
            bookineTravelerTwo.TravelerType = "ADT";
            bookineTravelerTwo.BookingTravelerName = new UniversalService.BookingTravelerName()
            {
                First = "Eliott",
                Last = "Greene",
                Prefix = "MR"
            };
            UniversalService.PhoneNumber phoneNumberTwo = new UniversalService.PhoneNumber()
            {
                AreaCode = "08",
                CountryCode = "61",
                Location = "PER",
                Number = "40003000",
                Type = UniversalService.PhoneNumberType.Home
            };

            bookineTravelerTwo.PhoneNumber = new UniversalService.PhoneNumber[1];
            bookineTravelerTwo.PhoneNumber[0] = phoneNumberTwo;


            UniversalService.Email emailTwo = new UniversalService.Email()
            {
                EmailID = "*****@*****.**",
                Type = "Home"
            };

            bookineTravelerTwo.Email = new UniversalService.Email[1];
            bookineTravelerTwo.Email[0] = emailTwo;

            UniversalService.typeStructuredAddress addressTwo = new UniversalService.typeStructuredAddress()
            {
                AddressName = "Home",
                Street = new[] { "10 Charlie Street" },
                City = "Perth",
                State = new UniversalService.State()
                {
                    Value = "WA"
                },
                PostalCode = "6000",
                Country = "AU"
            };

            bookineTravelerTwo.Address = new UniversalService.typeStructuredAddress[1];
            bookineTravelerTwo.Address[0] = addressTwo;

            hotelCreateReservationReq.BookingTraveler = new UniversalService.BookingTraveler[2];
            hotelCreateReservationReq.BookingTraveler[0] = bookingTravelerOne;
            hotelCreateReservationReq.BookingTraveler[1] = bookineTravelerTwo;

            HotelService.GuaranteeInfo hotelGurrenteeInfo = null;
            //select a hotel rate details and book the hotel using that one
            RequestedHotelDetails reqHotelDetails = (RequestedHotelDetails)hotelDetailsResponse.Item;
            if (reqHotelDetails.HotelRateDetail.Count() > 0)
            {
                IEnumerator<HotelService.HotelRateDetail> rateDetails = reqHotelDetails.HotelRateDetail.ToList().GetEnumerator();
                if (rateDetails.MoveNext())
                {
                    HotelService.HotelRateDetail rateDetail = rateDetails.Current;
                    hotelCreateReservationReq.HotelRateDetail = new UniversalService.HotelRateDetail()
                    {
                        ApproximateBase = rateDetail.ApproximateBase ?? null,
                        ApproximateRateGuaranteed = rateDetail.ApproximateRateGuaranteed,
                        ApproximateRateGuaranteedSpecified = rateDetail.ApproximateRateGuaranteedSpecified,
                        ApproximateSurcharge = rateDetail.ApproximateSurcharge ?? null,
                        ApproximateTax = rateDetail.ApproximateTax ?? null,
                        ApproximateTotal = rateDetail.ApproximateTotal ?? null,
                        Base = rateDetail.Base ?? null,
                        RateCategory = rateDetail.RateCategory ?? null,
                        RatePlanType = rateDetail.RatePlanType ?? null,              
                        RateOfferId = rateDetail.RateOfferId ?? null,
                        Tax = rateDetail.Tax ?? null,
                        RateSupplier = rateDetail.RateSupplier ?? null,
                        Total = rateDetail.Total ?? null
                    };

                    hotelGurrenteeInfo = rateDetail.GuaranteeInfo;
                }
            }


            hotelCreateReservationReq.HotelProperty = new UniversalService.HotelProperty()
            {
                HotelChain = reqHotelDetails.HotelProperty.HotelChain ?? null,
                HotelCode = reqHotelDetails.HotelProperty.HotelCode ?? null,
                HotelLocation = reqHotelDetails.HotelProperty.HotelLocation ?? null,
                Name = reqHotelDetails.HotelProperty.Name ?? null,
                PropertyAddress = reqHotelDetails.HotelProperty.PropertyAddress ?? null,
            };

            hotelCreateReservationReq.HotelStay = new UniversalService.HotelStay()
            {
                CheckinDate = GetHotelStay().CheckinDate,
                CheckoutDate = GetHotelStay().CheckoutDate
            };

            //create payment info
            UniversalService.CreditCard ccInfo= new UniversalService.CreditCard()
            {
                BankCountryCode = GetCreditCardDetails().BankCountryCode,
                BankName = GetCreditCardDetails().BankName,
                Number = GetCreditCardDetails().Number,
                Type = GetCreditCardDetails().Type,
                ExpDate = GetCreditCardDetails().ExpDate,
                Name = bookingTravelerOne.BookingTravelerName.First + bookingTravelerOne.BookingTravelerName.Last,
                CVV = GetCreditCardDetails().CVV
            };


            //check if guarantee tyoe is Deopsit or not
            if (hotelGurrenteeInfo.GuaranteeType.ToString().CompareTo((HotelService.GuaranteeType.Deposit.ToString())) == 0)
            {
                hotelCreateReservationReq.Guarantee = new UniversalService.Guarantee()
                {
                    Type = UniversalService.GuaranteeType.Deposit,
                    Item = ccInfo
                };
            }
            else if (hotelGurrenteeInfo.GuaranteeType.ToString().CompareTo((HotelService.GuaranteeType.Guarantee.ToString())) == 0)
            {
                hotelCreateReservationReq.Guarantee = new UniversalService.Guarantee()
                {
                    Type = UniversalService.GuaranteeType.Guarantee,
                    Item = ccInfo
                };
            }

            hotelCreateReservationReq.GuestInformation = new UniversalService.GuestInformation()
            {
                NumberOfRooms = numberOfRooms,
                NumberOfAdults = new UniversalService.NumberOfAdults()
                {
                    Value = numberOfAdults.ToString()
                }
            };

            if (hostToken != null && hostToken.Value != null)
            {
                hotelCreateReservationReq.HostToken = new UniversalService.HostToken()
                {
                    Host = hostToken.Host,
                    Key = hostToken.Key ?? null,
                    Value = hostToken.Value
                };
            }



            HotelReservationServicePortTypeClient hotelBookclient = new HotelReservationServicePortTypeClient("HotelReservationServicePort", WsdlService.HOTEL_ENDPOINT);
            hotelBookclient.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
            hotelBookclient.ClientCredentials.UserName.Password = Helper.ReturnPassword();

            try
            {
                var httpHeaders = Helper.ReturnHttpHeader();
                hotelBookclient.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));

                hotelCreateReservationRsp = hotelBookclient.service(null, hotelCreateReservationReq);                
            }
            catch (Exception se)
            {
                Console.WriteLine("Error : " + se.Message);
                hotelBookclient.Abort();
            }

            return hotelCreateReservationRsp;
        }
示例#36
0
 public ResponseModel Delete(HotelService hotelService)
 {
     return _hotelServiceRepository.Delete(hotelService);
 }
示例#37
0
 public ResponseModel Insert(HotelService hotelService)
 {
     return _hotelServiceRepository.Insert(hotelService);
 }