Ejemplo n.º 1
0
        // GET api/RideController

        /// <summary>
        /// To fetch the travel history for the passenger and driver
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="type">Cab Type</param>
        /// <returns>
        ///     <param name="status">Status of the API request</param>
        ///     <param name="message">Response message</param>
        /// </returns>
        public Response Get(int Id, string type)
        {
            AppDao   dbobj       = new AppDao();
            Response responseobj = new Response();
            Response_Travel_History resultobj = new Response_Travel_History();

            try
            {
                string query;
                //Fetch the travel history for the specfied person_id
                if (string.Compare(type, "Passenger") == 0)
                {
                    //Passenger is given the vehicle id
                    query     = "SELECT COUNT(Vehicle_id) as number_of_rides, start_location_lat,start_location_lon,end_location_lat,end_location_lon FROM Travel_History WHERE Vehicle_id = " + Id + "";
                    resultobj = dbobj.GetTravelDetails(query);
                }
                else if (string.Compare(type, "Driver") == 0)
                {
                    //Driver has given the passenger id
                    query     = "SELECT COUNT(Passenger_id) as number_of_rides, start_location_lat,start_location_lon,end_location_lat,end_location_lon FROM Travel_History WHERE Passenger_id = " + Id + "";
                    resultobj = dbobj.GetTravelDetails(query);
                }

                responseobj.status  = "Sucess";
                responseobj.message = JsonConvert.SerializeObject(resultobj);
            }
            catch (Exception ex)
            {
                responseobj.status  = "Failed";
                responseobj.message = "Travel history Failed with error -> " + ex.Message;
            }
            return(responseobj);
        }