Esempio n. 1
0
        private AvailabilityResponse Dummy()
        {
            Random rnd      = new Random();
            var    response = new AvailabilityResponse();

            response.Rooms.Add(new Availability {
                Room = new Room {
                    Description = "Minimalist room for the economist traveller.", Title = "Sleep Dorm", Id = "1", Rate = 1597
                }, AvailableCount = rnd.Next(1, 10)
            });
            response.Rooms.Add(new Availability {
                Room = new Room {
                    Description = "Just the basics - bed and bathroom with shower.", Title = "RnR", Id = "2", Rate = 899
                }, AvailableCount = rnd.Next(1, 10)
            });
            response.Rooms.Add(new Availability {
                Room = new Room {
                    Description = "Bedroom with workspace for the business traveller.", Title = "Working Suite", Id = "3", Rate = 2499
                }, AvailableCount = rnd.Next(1, 10)
            });
            response.Rooms.Add(new Availability {
                Room = new Room {
                    Description = "Private office space with minimalist sleeping quarters.", Title = "Office Away", Id = "4", Rate = 1200
                }, AvailableCount = rnd.Next(1, 10)
            });
            response.Rooms.Add(new Availability {
                Room = new Room {
                    Description = "Sleeping, living and dining accomodations.", Title = "Home Away", Id = "5", Rate = 4000
                }, AvailableCount = rnd.Next(1, 10)
            });
            return(response);
        }
Esempio n. 2
0
        public static void MapResponseToDB(AvailabilityRes value, string SessionID)
        {
            try {
                HotelBedEntities     db           = new HotelBedEntities();
                AvailabilityResponse availability = new AvailabilityResponse();
                availability.Currency   = value.hotel.currency;
                availability.TotalPrice = value.hotel.totalNet;
                availability.response   = Newtonsoft.Json.JsonConvert.SerializeObject(value.hotel);
                availability.SearchID   = SessionID;
                var hotel = db.SearchHotelDatas.FirstOrDefault(a => a.SessionID == SessionID);
                availability.SearchHotelID = hotel.Id;
                db.AvailabilityResponses.Add(availability);
                db.SaveChanges();
                foreach (var room in value.hotel.rooms)
                {
                    foreach (var rate in room.rates)
                    {
                        SearchRoom searchRoom = new SearchRoom();
                        searchRoom.adults = rate.adults;

                        searchRoom.boardCode      = rate.boardCode;
                        searchRoom.boardName      = rate.boardName;
                        searchRoom.children       = rate.children;
                        searchRoom.childrenAges   = rate.childrenAges;
                        searchRoom.hotelMandatory = rate.hotelMandatory.ToString();
                        searchRoom.netPrice       = rate.net;
                        searchRoom.packaging      = rate.packaging.ToString();
                        searchRoom.paymentType    = rate.paymentType;
                        searchRoom.rateClass      = rate.rateClass;
                        searchRoom.rateKey        = rate.rateKey;
                        searchRoom.rateType       = rate.rateType;
                        searchRoom.ResponseType   = "availability";
                        searchRoom.RoomCode       = room.code;
                        searchRoom.RoomName       = room.name;
                        searchRoom.rooms          = rate.rooms;
                        searchRoom.SearchHotelID  = availability.ID;
                        searchRoom.sessionID      = SessionID;
                        searchRoom.sellingRate    = rate.sellingRate;
                        db.SearchRooms.Add(searchRoom);
                        db.SaveChanges();
                        foreach (var p in rate.cancellationPolicies)
                        {
                            RoomPolicy policy = new RoomPolicy();
                            policy.amount      = p.amount;
                            policy.fromDate    = p.from.ToString();;
                            policy.RoomID      = searchRoom.Id;
                            policy.CallingType = "check";
                            db.RoomPolicies.Add(policy);
                        }
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                var requestData = JsonConvert.SerializeObject(ex);

                LogData.WriteToFile("c:/HotelsB2C/Logs/HBLogs/AvailabilityException", "AvailabilityException_" + SessionID, "AvailabilityException", requestData);
            }
        }
        public AvailabilityResponse ProcessAvailability(HotelAvailabilityResponse response)
        {
            var result = new AvailabilityResponse();

            result.CheckIn  = response.CheckIn;
            result.CheckOut = response.CheckOut;
            var availableHotels = new List <AvailableHotel>();

            foreach (var hotels in response.AvailableHotels)
            {
                var hotel = new AvailableHotel();

                hotel.Code = hotels.Code;

                var rooms = new List <AvailableRoom>();
                foreach (var room in hotels.AvailableRooms)
                {
                    var data = new AvailableRoom();
                    data.Id       = room.Id;
                    data.Code     = room.Code;
                    data.Price    = room.Price;
                    data.NewPrice = _pricingService.CalculatePrice(response.CheckIn, response.CheckOut, room.Price);
                    rooms.Add(data);
                }
                hotel.AvailableRooms = rooms;

                availableHotels.Add(hotel);
            }

            result.AvailableHotels = availableHotels;


            return(result);
        }
Esempio n. 4
0
        protected bool DoesCloudServiceExist(string serviceName)
        {
            Func <string, AvailabilityResponse> func = null;
            bool result = false;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                try
                {
                    NewAzureVMCommand newAzureVMCommand = this;
                    if (func == null)
                    {
                        func = (string s) => base.Channel.IsDNSAvailable(s, serviceName);
                    }
                    AvailabilityResponse availabilityResponse = ((CmdletBase <IServiceManagement>)newAzureVMCommand).RetryCall <AvailabilityResponse>(func);
                    base.WaitForOperation(base.CommandRuntime.ToString(), true);
                    result = !availabilityResponse.Result;
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    if (communicationException as EndpointNotFoundException == null)
                    {
                        this.WriteErrorDetails(communicationException);
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            return(result);
        }
Esempio n. 5
0
        public async Task <IActionResult> Availability([FromQuery, BindRequired] AvailabilityReqeust request)
        {
            var pilot = await _mediator.Send(new AvailabilityQuery
            {
                Base = request.Base,
                DepartureDateTime = request.DepartureDateTime.Value,
                ReturnDateTime    = request.ReturnDateTime.Value
            });

            if (pilot == default)
            {
                return(NotFound("No pilots were available for the requested base and period."));
            }

            var response = new AvailabilityResponse
            {
                Pilot = new Pilot {
                    Id = pilot.Id, Name = pilot.Name
                },
                Base = pilot.Base,
                DepartureDateTime = request.DepartureDateTime.Value.ToString("dddd, MMMM dd, yyyy h:mm tt"),
                ReturnDateTime    = request.ReturnDateTime.Value.ToString("dddd, MMMM dd, yyyy h:mm tt")
            };

            return(Ok(response));
        }
Esempio n. 6
0
        protected bool DoesCloudServiceExist(string serviceName)
        {
            bool IsPresent = false;

            using (new OperationContextScope(Channel.ToContextChannel()))
            {
                try
                {
                    WriteVerboseWithTimestamp(string.Format(Resources.QuickVMBeginOperation, CommandRuntime.ToString()));
                    AvailabilityResponse response = this.RetryCall(s => this.Channel.IsDNSAvailable(s, serviceName));
                    WriteVerboseWithTimestamp(string.Format(Resources.QuickVMCompletedOperation, CommandRuntime.ToString()));
                    IsPresent = !response.Result;
                }
                catch (ServiceManagementClientException ex)
                {
                    if (ex.HttpStatus == HttpStatusCode.NotFound)
                    {
                        IsPresent = false;
                    }
                    else
                    {
                        this.WriteErrorDetails(ex);
                    }
                }
            }
            return(IsPresent);
        }
        private bool StorageAccountExists()
        {
            ClientOutputMessageInspector messageInspector;
            IServiceManagement           serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector);
            AvailabilityResponse         response     = serviceProxy.CheckStorageAccountNameAvailability(this._subscriptionId, this.StorageAccount);

            if (response.Result == false) //If storage account already exists..verify if it is located in same location supplied in input parameter.
            {
                StorageService storageAcctProperties;
                try
                {
                    storageAcctProperties = serviceProxy.GetStorageAccountProperties(this._subscriptionId, this.StorageAccount);
                }
                catch (EndpointNotFoundException)
                {
                    throw new ApplicationFailedException(string.Format(CultureInfo.InvariantCulture, Resources.StorageAccExistsForDiffSubscription, this.StorageAccount));
                }

                if (string.IsNullOrEmpty(Location) == false &&
                    Location.Trim().ToUpperInvariant() != storageAcctProperties.StorageServiceProperties.Location.ToUpperInvariant())
                {
                    WriteWarning(Resources.StorageAccDiffLocationWarning);
                }
            }
            return(!response.Result);
        }
Esempio n. 8
0
        public AvailabilityResponse IsStorageServiceAvailable(string subscriptionId, string name)
        {
            AvailabilityResponse result = Channel.IsStorageServiceAvailable(subscriptionId, name);

            WriteObject(!result.Result);

            return(result);
        }
Esempio n. 9
0
        public IHttpActionResult Availability(AvailabilityRequest request)
        {
            List <AttendeeInfo> attendees = new List <AttendeeInfo>();

            foreach (var user in request.Users)
            {
                attendees.Add(new AttendeeInfo()
                {
                    SmtpAddress  = user,
                    AttendeeType = MeetingAttendeeType.Required
                });
            }

            // Specify availability options.
            AvailabilityOptions myOptions = new AvailabilityOptions();

            myOptions.MeetingDuration       = request.DurationMinutes;
            myOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;

            // Return a set of free/busy times.
            var service = ExchangeServer.Open();

            var startTime = DateTime.Parse(request.Start);
            var endTime   = DateTime.Parse(request.End);
            GetUserAvailabilityResults freeBusyResults = service.GetUserAvailability(attendees,
                                                                                     new TimeWindow(startTime, endTime),
                                                                                     AvailabilityData.FreeBusy,
                                                                                     myOptions);

            var response = new AvailabilityResponse
            {
                AvailabilityResult = new List <AvailabilityUser>()
            };


            foreach (AttendeeAvailability availability in freeBusyResults.AttendeesAvailability)
            {
                var user  = new AvailabilityUser();
                var avail = new List <TimeBlock>();

                foreach (CalendarEvent calendarItem in availability.CalendarEvents)
                {
                    var block = new TimeBlock
                    {
                        Start      = calendarItem.StartTime,
                        End        = calendarItem.EndTime,
                        StatusEnum = calendarItem.FreeBusyStatus,
                        Status     = calendarItem.FreeBusyStatus.ToString()
                    };

                    avail.Add(block);
                }
                user.Availability = avail;
                response.AvailabilityResult.Add(user);
            }

            return(Ok(response));
        }
        public IActionResult Get(DateTime date)
        {
            var response = new AvailabilityResponse()
            {
                Price     = _rnd.Next(1) == 0 ? 120 : 150,
                RoomCount = _rnd.Next(3)
            };

            return(Ok(response));
        }
Esempio n. 11
0
        public BookingResponse SubmitBooking(int ordernumber, AvailabilityResponse availability, List <BookingTransactionDetail> bookingDetails)
        {
            var bookingRequest = new BookingRequest
            {
                AgentUID              = _agentUiId,
                AgentCode             = _agentCode,
                ApiKey                = _apiKey,
                SupplierTranReference = ordernumber.ToString(),
                TransactionDetails    = bookingDetails.ToArray(),
                TransactionReference  = availability.TransactionReference
            };

            var bookingResponse = _clientApi.Booking(bookingRequest);

            return(bookingResponse);
        }
Esempio n. 12
0
 public AvailabilityService()
 {
     this.ws              = new AvailabilityRequest();
     this.reg             = new RegionalAvailabilityExtRequest();
     this.cli             = new AvailabilityServiceSoapClient();
     this.og              = new OGHeader();
     this.origin          = new EndPoint();
     this.dest            = new EndPoint();
     this.segment         = new AvailRequestSegment();
     this.hotelSearch     = new HotelSearchCriterion();
     this.hotelRef        = new HotelReference();
     this.roomStay        = new RoomStayCandidate();
     this.request         = new AvailabilityRequest();
     this.packageRequest  = new FetchAvailablePackagesRequest();
     this.timeSpan        = new Availability.TimeSpan();
     this.rate            = new MinMaxRate();
     this.response        = new AvailabilityResponse();
     this.packageResponse = new FetchAvailablePackagesResponse();
     this.ratePlan        = new RatePlanCandidate();
     this.tempObj         = new Object();
 }
Esempio n. 13
0
        public async Task <AvailabilityResponse> GetAvailability(AvailabilityRequest request)
        {
            var response = new AvailabilityResponse();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(_url);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage resp = await client.PostAsJsonAsync("/api/appointments/availability", request);

                if (resp.IsSuccessStatusCode)
                {
                    response = await resp.Content.ReadAsAsync <AvailabilityResponse>();

                    return(response);
                }
            }
            return(response);
        }
Esempio n. 14
0
        private async Task <AvailabilityResponse> FetchAvailability(string date, string ticketId)
        {
            try
            {
                AvailabilityRequestModel input = new AvailabilityRequestModel();
                input.data                = new Data();
                input.request_type        = "availabilities";
                input.data.distributor_id = _settings.GetConfigSetting <string>(SettingKeys.Integration.CitySightSeeing.DistributorId);
                AvailabilityResponse objData = new AvailabilityResponse();
                input.data.from_date = date;
                input.data.to_date   = date;
                input.data.ticket_id = ticketId;
                objData = Mapper <AvailabilityResponse> .MapFromJson((await Get(input)));

                return(objData);
            }
            catch (Exception ex)
            {
                _logger.Log(LogCategory.Error, new Exception("Failed to Fetch CitySightSeeing Avaikability", ex));
                return(null);
            }
        }
Esempio n. 15
0
        public Object GetAvailableRooms(DateTime startDate, DateTime endDate, int numRoom = 1, int numAdult = 1, int numChild = 0, string rateType = "normal", string rateCode = "", string currencyCode = "PHP", string chainCode = "CHA", string hotelCode = "WCCH")
        {
            this._InitializeHeader();

            this.request.summaryOnly = true;

            /** /
             * this.ratePlan.ratePlanCode = "OWCCH";
             * this.roomStay.roomTypeCode = "SUPK";
             * this.segment.RatePlanCandidates = new RatePlanCandidate[1];
             * this.segment.RatePlanCandidates[0] = this.ratePlan;
             * /**/

            this._InitializeTimeSpan(startDate, endDate);

            this.rate.currencyCode         = currencyCode;
            this.rate.minimumRateSpecified = true;
            this.rate.maximumRateSpecified = true;
            this.rate.decimals             = 2;
            this.rate.decimalsSpecified    = true;
            this.rate.minimumRate          = 1.00;
            this.rate.maximumRate          = 1000000.00;

            this.segment.numberOfRooms                = numRoom;
            this.segment.numberOfRoomsSpecified       = true;
            this.segment.totalNumberOfGuests          = numAdult;
            this.segment.totalNumberOfGuestsSpecified = true;
            this.segment.numberOfChildren             = numChild;
            this.segment.numberOfChildrenSpecified    = true;
            this.segment.availReqType = AvailRequestType.Room;


            this._InitializeHotelRef(chainCode, hotelCode);

            this.roomStay.invBlockCode = null;

            this.segment.HotelSearchCriteria = new HotelSearchCriterion[1];
            this.segment.RoomStayCandidates  = new RoomStayCandidate[1];
            this.request.AvailRequestSegment = new AvailRequestSegment[1];

            this.segment.HotelSearchCriteria[0] = this.hotelSearch;
            this.segment.RoomStayCandidates[0]  = this.roomStay;
            this.segment.RateRange     = this.rate;
            this.segment.StayDateRange = this.timeSpan;

            switch (rateType)
            {
            case "corporate":
                this.segment.RatePlanCandidates    = new Availability.RatePlanCandidate[1];
                this.segment.RatePlanCandidates[0] = new Availability.RatePlanCandidate();
                this.segment.RatePlanCandidates[0].qualifyingIdType  = "CORPORATE";
                this.segment.RatePlanCandidates[0].qualifyingIdValue = rateCode;
                break;

            case "travelAgent":
                this.segment.RatePlanCandidates    = new Availability.RatePlanCandidate[1];
                this.segment.RatePlanCandidates[0] = new Availability.RatePlanCandidate();
                this.segment.RatePlanCandidates[0].qualifyingIdType  = "TRAVEL_AGENT";
                this.segment.RatePlanCandidates[0].qualifyingIdValue = rateCode;
                break;

            case "promotion":
                this.segment.RatePlanCandidates    = new Availability.RatePlanCandidate[1];
                this.segment.RatePlanCandidates[0] = new Availability.RatePlanCandidate();
                this.segment.RatePlanCandidates[0].promotionCode = rateCode;
                break;

            case "normal":
            default:
                break;
            }

            this.request.AvailRequestSegment[0] = this.segment;
            try
            {
                response = this.response = cli.Availability(ref this.og, this.request);
            }
            catch (Exception e)
            {
                this.errors = e;
            }


            if (response.Result.GDSError == null)
            {
                var temp_result = new
                {
                    statusCode     = 0,
                    statusMessage  = "",
                    roomTypes      = response.AvailResponseSegments[0].RoomStayList[0].RoomTypes,
                    roomTypesCount = response.AvailResponseSegments[0].RoomStayList[0].RoomTypes.Count <RoomType>(),
                    roomRates      = response.AvailResponseSegments[0].RoomStayList[0].RoomRates,
                    roomRatesCount = response.AvailResponseSegments[0].RoomStayList[0].RoomRates.Count <RoomRate>()
                };
                this.tempObj = temp_result;
            }
            else
            {
                var temp_result = new
                {
                    statusCode     = response.Result.GDSError.errorCode,
                    statusMessage  = response.Result.GDSError.Value,
                    roomTypes      = "",
                    roomTypesCount = "",
                    roomRates      = "",
                    roomRatesCount = ""
                };
                this.tempObj = temp_result;
            }
            this.finalResponse.Add(this.tempObj);
            //return this.finalResponse;
            return(this.tempObj);
            //return response;
        }
        private static async Task GetAvailabilityAsync()
        {
            AvailabilityResponse availability = await _client.GetAvailabilityAsync();

            PrintResponse(availability.Availability);
        }
Esempio n. 17
0
        //from, to, roomtype, city
        public AvailabilityResponse GetAvailableRoomList(AvailabilityRequest request)
        {
            var response = new AvailabilityResponse();

            try
            {
                using (var context = new SpartanHotelsEntities())
                {
                    var aviRooms = from hr in context.HotelRooms
                                   join ht in context.Hotels on hr.HotelID equals ht.HotelID
                                   where ht.City == request.City
                                   select new
                    {
                        hr.HotelRoomID,
                        hr.HotelID,
                        ht.HotelName,
                        hr.Rate,
                        hr.TotalRoomCount,
                        hr.RoomTypeID,
                        ht.City,
                        ht.Locality,
                        ht.Address,
                    };

                    var aviReservations = from rs in context.Reservations
                                          where
                                          (rs.FromDate >= request.FromDate && rs.FromDate <= request.ToDate &&
                                           rs.BookStatusID == (int)BookingStatus.Confirmed)
                                          select rs;

                    if (aviReservations.Any())
                    {
                        var totalBooking =
                            aviReservations.GroupBy(tb => new { tb.FromDate, tb.HotelRoomID }).Select(room => new
                        {
                            room.Key.HotelRoomID,
                            room.Key.FromDate,
                            Total = room.Count()
                        }).AsQueryable().GroupBy(a => new { a.HotelRoomID }).Select(b => new
                        {
                            b.Key.HotelRoomID,
                            TotalBookedRooms = b.Max(c => c.Total)
                        }).AsQueryable();

                        foreach (var avi in aviRooms)
                        {
                            var filteredRoom = totalBooking.FirstOrDefault(a => a.HotelRoomID == avi.HotelRoomID);
                            int roomsBooked  = 0;

                            if (filteredRoom != null)
                            {
                                roomsBooked = filteredRoom.TotalBookedRooms;
                            }

                            if (avi.TotalRoomCount > roomsBooked)
                            {
                                response.Rooms.Add(new Availability()
                                {
                                    Room = new SpartanHotels.Entities.Room
                                    {
                                        Id    = avi.HotelRoomID.ToString(),
                                        Title = avi.RoomTypeID.ToString(),
                                        Rate  = (decimal)avi.Rate
                                    },

                                    AvailableCount = (int)avi.TotalRoomCount - roomsBooked
                                });
                            }
                        }
                    }
                    else
                    {
                        foreach (var avi in aviRooms)
                        {
                            if (avi.TotalRoomCount > 0)
                            {
                                response.Rooms.Add(new Availability()
                                {
                                    Room = new Entities.Room
                                    {
                                        Id    = avi.HotelRoomID.ToString(),
                                        Title = avi.RoomTypeID.ToString(),
                                        Rate  = (decimal)avi.Rate
                                    },

                                    AvailableCount = (int)avi.TotalRoomCount
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(response);
        }
        public AvailabilityResponse EndIsStorageServiceAvailable(IAsyncResult asyncResult)
        {
            AvailabilityResponse availabilityResponse = new AvailabilityResponse();

            if (IsStorageServiceAvailableThunk != null)
            {
                SimpleServiceManagementAsyncResult result = asyncResult as SimpleServiceManagementAsyncResult;
                Assert.IsNotNull(result, "asyncResult was not SimpleServiceManagementAsyncResult!");

                availabilityResponse = IsStorageServiceAvailableThunk(result);
            }
            else if (ThrowsIfNotImplemented)
            {
                throw new NotImplementedException("IsStorageServiceAvailableThunk is not implemented!");
            }

            return availabilityResponse;
        }
Esempio n. 19
0
 public void Init()
 {
     instance = new AvailabilityResponse();
 }