1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
|
[WebMethod(EnableSession=true)]
public CookieBase Search(SearchRequest searchRequest)
{
search.Query.LanguageCode = "en";
Tools.SearchQuery s = null;
try
{
s = Tools.Search.CreateSearch(search.Serialize(), QueryAdapter.GetCityDescription(searchRequest.CityCode), searchRequest.CheckIn, searchRequest.Nights, searchRequest.StarsRate);
}
catch (Exception ex)
{
return new ErrorResponse(ex.ToString(), searchRequest);
}
//Performing query
s.Hotels = search.Hotels;
string tabHeader = searchRequest.CityName + " - " + search.Hotels.Count,
bodyHeader = "<div class='title_search fixAlignCenter'>";
string nightStr = (search.Hotels.Count > 1) ? "night" : "nights";
string[] month = new string[13] { "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
switch (search.Hotels.Count)
{
case 0:
bodyHeader += "No hotels found matching your search parameters";
break;
case 1:
bodyHeader += String.Format("We found one hotelin {0} on {1} {2} {3} for {4} {5}", s.City, s.CheckIn.ToString("dd"), month[s.CheckIn.Month], s.CheckIn.ToString("yyyy"), s.Nights, nightStr);
break;
default:
bodyHeader += String.Format("We found {0} hotels in {1} on {2} {3} {4} for {5} {6}", search.Hotels.Count, s.City, s.CheckIn.ToString("dd"), month[s.CheckIn.Month], s.CheckIn.ToString("yyyy"), s.Nights, nightStr);
break;
}
bodyHeader += "</div>";
SearchResponse result = new SearchResponse(s.ID, tabHeader, bodyHeader, searchRequest);
System.Collections.Generic.List<HotelItem> items = new System.Collections.Generic.List<HotelItem>();
foreach (Hotel hotel in s.Hotels)
{
if (hotel.Info.GeoCodes != null)
{
try
{
double latitude = double.Parse(hotel.Info.GeoCodes.Latitude, System.Globalization.CultureInfo.InvariantCulture);
double longitude = double.Parse(hotel.Info.GeoCodes.Longitude, System.Globalization.CultureInfo.InvariantCulture);
double TotalStayPriceEUR = 0,
TotalStayPriceUSD = 0,
TotalStayPriceGBP = 0;
if (hotel.RoomClases != null && hotel.RoomClases.Count > 0)
{
foreach (Bepro.Common.RoomClass roomClass in hotel.RoomClases)
{
if (roomClass.HotelRooms == null || roomClass.HotelRooms.Count == 0)
continue;
Bepro.Common.HotelRoom room = roomClass.HotelRooms[0];
if (TotalStayPriceUSD == 0 || TotalStayPriceEUR < roomClass.Price.Gross.EUR)
{
TotalStayPriceEUR = roomClass.Price.Gross.EUR;
TotalStayPriceUSD = roomClass.Price.Gross.USD;
TotalStayPriceGBP = roomClass.Price.Gross.GBP;
}
}
}
items.Add(new HotelItem(hotel.Item.Desc,
latitude, longitude,
(short)hotel.SortByStar,
TotalStayPriceEUR, TotalStayPriceUSD, TotalStayPriceGBP,
String.Format("?hotel={0}&city={1}&supplier={2}", hotel.Item.Code, hotel.City.SysCode, hotel.SysSupp.SysCode)
));
}
catch (Exception) { }
}
}
//ClientScript.RegisterClientScriptBlock(this.GetType(), "hotels", String.Format("var hotels = {0};\n", Serializer.Serialize(items)), true);
result.Items = items;
return result;
}
private static GeoTableAdapters.QueriesTableAdapter m_queryAdapter = null;
private GeoTableAdapters.QueriesTableAdapter QueryAdapter
{
get
{
if (m_queryAdapter == null)
m_queryAdapter = new GeoTableAdapters.QueriesTableAdapter();
return m_queryAdapter;
}
|