コード例 #1
0
        public HttpResponseMessage SharecabRequest([FromBody] ShareCabModel objShareCabModel)
        {
            var re      = Request;
            var headers = re.Headers;

            if (headers.Contains("token"))
            {
                token = headers.GetValues("token").First();
            }

            var result = Authtoken.checkToken(token);

            if (result == true)
            {
                ShareCabId = objSharecabDL.insert_sharecab(objShareCabModel);
                objShareCabModel.sharecabid = ShareCabId;
                dt = objSharecabDL.GetResponce(objShareCabModel);

                var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK,
                                                                  new ResponseModel()
                {
                    message = "ok successfull", output = dt, statuscode = Convert.ToInt16(HttpStatusCode.OK)
                });
                return(resp);
            }
            else
            {
                var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel()
                {
                    message = "UnAuthorized", statuscode = Convert.ToInt16(HttpStatusCode.OK), error = true
                });
                return(resp);
            }
        }
コード例 #2
0
        public HttpResponseMessage SharecabResponse([FromBody] ShareCabModel objShareCabModel)
        {
            apiKey = System.Configuration.ConfigurationManager.AppSettings["apikey"];
            DataSet ds = new DataSet();

            dt3 = objSharecabDL.GetResponce(objShareCabModel);
            if (dt3.Rows[0][4] != null)
            {
                emplatlong    = dt3.Rows[0]["empLatitude"].ToString() + "," + dt3.Rows[0]["empLongitude"].ToString();
                driverlatlong = dt3.Rows[0]["driverLatitude"].ToString() + "," + dt3.Rows[0]["driverLongitude"].ToString();

                url = @"https://maps.googleapis.com/maps/api/distancematrix/xml?&origins=" + driverlatlong + "&destinations=" + emplatlong + "&key=" + apiKey + "";

                HttpWebRequest request        = (HttpWebRequest)WebRequest.Create(url);
                WebResponse    response       = request.GetResponse();
                Stream         dataStream     = response.GetResponseStream();
                StreamReader   sreader        = new StreamReader(dataStream);
                string         responsereader = sreader.ReadToEnd();
                response.Close();


                ds.ReadXml(new XmlTextReader(new StringReader(responsereader)));
            }
            if (ds.Tables.Count > 0)
            {
                if (ds.Tables["element"].Rows[0]["status"].ToString() == "OK")
                {
                    dt = ds.Tables["distance"];
                }

                ds.Merge(dt3);
                var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK,
                                                                  new ResponseModel()
                {
                    message = "your details", output = ds, statuscode = Convert.ToInt16(HttpStatusCode.OK)
                });
                return(resp);
            }

            else
            {
                var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel()
                {
                    message = "UnAuthorized", statuscode = Convert.ToInt16(HttpStatusCode.OK), error = true
                });
                return(resp);
            }
        }
コード例 #3
0
 public DataTable GetResponce(ShareCabModel objShareCabModel)
 {
     try
     {
         return(Execution.ExecuteParamerizedSelectCommand("sp_sharecab", new SqlParameter[]
         {
             new SqlParameter("@empid", objShareCabModel.empid),
             new SqlParameter("@sharecabid", objShareCabModel.sharecabid),
             new SqlParameter("@Command", "GETRESPONSE"),
         }));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #4
0
        public int AcceptbyDriver(ShareCabModel objShareCabModel)
        {
            try
            {
                return(Execution.ExecuteNonQuery_with_result("sp_sharecab", new SqlParameter[]
                {
                    new SqlParameter("@Command", "INSERT"),


                    new SqlParameter("@empid", objShareCabModel.empid),
                    new SqlParameter("@presentLatitude", objShareCabModel.presentlatitude),
                    new SqlParameter("@presentLongitude", objShareCabModel.presentlongitude),


                    new SqlParameter("@status", 1),
                }));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }