예제 #1
0
        public JsonResult SerachFlight(FlightSearchParameter objserch)
        {
            try
            {
                string datefrm = null;
                string dateTo  = null;

                if (objserch.Tripmode == "1")
                {
                    DateTime datefrm11 = Convert.ToDateTime(objserch.FromDate);
                    datefrm = datefrm11.ToString("yyyy-MM-dd");
                    dateTo  = null;
                }
                else if (objserch.Tripmode == "2")
                {
                    DateTime datefrm11 = Convert.ToDateTime(objserch.FromDate);
                    datefrm = datefrm11.ToString("yyyy-MM-dd");

                    DateTime date_to = Convert.ToDateTime(objserch.ToDate);

                    dateTo = date_to.ToString("yyyy-MM-dd");
                }
                var GetTokenValue = GetToken();

                FlightSearch objflightsearch = new FlightSearch();
                objflightsearch.TokenId                = GetTokenValue;
                objflightsearch.AdultCount             = objserch.Adult;
                objflightsearch.ChildCount             = objserch.Child;
                objflightsearch.InfantCount            = objserch.Infant;
                objflightsearch.DirectFlight           = "false";
                objflightsearch.OneStopFlight          = "false";
                objflightsearch.JourneyType            = objserch.Tripmode;
                objflightsearch.PreferredAirlines      = null;
                objflightsearch.Origin                 = objserch.FromCityCode;
                objflightsearch.Destination            = objserch.TOAirportCode;
                objflightsearch.FlightCabinClass       = objserch.TravelType;
                objflightsearch.PreferredDepartureTime = datefrm;
                objflightsearch.PreferredArrivalTime   = dateTo;
                objflightsearch.Sources                = "6E";

                dynamic searchflight = Tek_TravelAPI.SerachFlight(objflightsearch);
                var     data         = JsonConvert.SerializeObject(searchflight);
                //var searchflight = Tek_TravelAPI.SerachFlight(GetTokenValue,"1","0","0","true", "false", "1", PreferredAirlines, "CCU","BOM","1", Date_from, datetovalue, "6E");
                string TraceId = searchflight.Response.TraceId;
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public static string GetToken()
        {
            var db = new DBContext();
            //var getToken = db.TBL_API_TOKEN.FirstOrDefault();
            //string retturndate = string.Empty;
            //if (getToken != null)
            //{
            //    //DateTime tokendate = Convert.ToDateTime(getToken.INSERTEDDATE.ToString("yyyy-MM-dd"));
            //    //DateTime TodayDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
            //    //if (tokendate == TodayDate)
            //    //{
            //    //    retturndate = getToken.TOKEN;
            //    //}
            //    //else
            //    //{
            //    //    var genToken = Tek_TravelAPI.FlightAPIGenerateToken("ENCORE", "ENCORE@1234");
            //    //    var objvaltoken = db.TBL_API_TOKEN.FirstOrDefault();
            //    //    if (objvaltoken != null)
            //    //    {
            //    //        objvaltoken.TOKEN = genToken.TokenId;
            //    //        objvaltoken.INSERTEDDATE = DateTime.Now;
            //    //        db.Entry(objvaltoken).State = System.Data.Entity.EntityState.Modified;
            //    //        db.SaveChanges();
            //    //    }
            //    //    else
            //    //    {
            //    //        TBL_API_TOKEN objval = new TBL_API_TOKEN()
            //    //        {
            //    //            TOKEN = genToken.TokenId,
            //    //            APINAME = "TEKTravel",
            //    //            TOKENTYPE = "Authenticate",
            //    //            INSERTEDDATE = DateTime.Now,
            //    //            STATUS = 1
            //    //        };
            //    //        db.TBL_API_TOKEN.Add(objval);
            //    //        db.SaveChanges();
            //    //    }
            //    //    retturndate = genToken.TokenId;
            //    //}
            //}
            var genToken = Tek_TravelAPI.FlightAPIGenerateToken("ENCORE", "ENCORE@1234");

            return(genToken.TokenId);
            //return retturndate;
        }