EmployeeModel CallApi(string id, string pass, string DeviceId, string offid) { EmployeeModel Em; try { WebRequest request = WebRequest.Create("http://online-corporate-traveller.amadeus.com/live/V17_2_0/webapi/api/UserLogin/DoLogin"); request.Method = "POST"; request.ContentType = "application/json"; Stream dataStream = request.GetRequestStream(); // getJson(date, direct, type, quantity, origin, desti); // JObject abc = new SearchRequest().GetJson(); byte[] byteArray = Encoding.UTF8.GetBytes(GetLoginJson(id, pass, DeviceId, offid)); request.ContentLength = byteArray.Length; dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (Stream receiveStream = Flight_Availability.GetStreamForResponse(response)) { StreamReader sr = new StreamReader(receiveStream); string responseFromServer = sr.ReadToEnd(); LoginResponse lr = JsonConvert.DeserializeObject <LoginResponse>(responseFromServer); if (lr.Email_ID != null) { Em = new EmployeeModel { FirstName = lr.First_Name, CustId = lr.Customer_ID, OffId = lr.OF_ID, EmpCode = lr.Employee_Code, Email = lr.Email_ID, TokenID = lr.TokenID }; Em.Allow_ticketing = (from s in lr.lstAdminSettings where s.Type_Keyword == "AllowTicketing" select s).FirstOrDefault().Value; Em.ALLOW_PREFERRED_FL = (from s in lr.lstAdminSettings where s.Type_Keyword == "ALLOW_PREFERRED_FL" select s).FirstOrDefault().Value; Em.Approval_mail = (from s in lr.lstAdminSettings where s.Type_Keyword == "ApprovalMail" select s).FirstOrDefault().Value; } else { Em = new EmployeeModel(); }; } dataStream.Close(); response.Close(); } catch (Exception ex) { throw ex; } return(Em); }
public string TripHistory(string CUSTOMER, string or, string dest, string Token) { string airpref = ""; string req = JsonConvert.SerializeObject(new HistoryRequest { CUSTOMER_ID = CUSTOMER, FL_FROM = or, FL_TO = dest, TokenID = Token }); try { WebRequest request = WebRequest.Create("http://online-corporate-traveller.amadeus.com/live/V17_2_0/webapi/api/Common/GetCustomerFlightFromTo"); request.Method = "POST"; request.ContentType = "application/json"; Stream dataStream = request.GetRequestStream(); // getJson(date, direct, type, quantity, origin, desti); // JObject abc = new SearchRequest().GetJson(); byte[] byteArray = Encoding.UTF8.GetBytes(req); request.ContentLength = byteArray.Length; dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (Stream receiveStream = Flight_Availability.GetStreamForResponse(response)) { StreamReader sr = new StreamReader(receiveStream); string responseFromServer = sr.ReadToEnd(); HistoryResponse hr = JsonConvert.DeserializeObject <HistoryResponse>(responseFromServer); if (hr != null && hr.lstGetCustomerFlightFromTo != null) { var results = from a in hr.lstGetCustomerFlightFromTo group a by a.FL_NO.ToString().Substring(0, 2) into newGroup select new { fl_no = newGroup.Key, fl_no_cnt = newGroup.Count() }; airpref = results.ToList().OrderByDescending(e => e.fl_no_cnt).FirstOrDefault().fl_no.ToString(); } else { airpref = "AI"; } //var results = hr.lstGetCustomerFlightFromTo.GroupBy(x => x.FL_NO); } dataStream.Close(); response.Close(); } catch (Exception ex) { throw ex; } return(airpref); }