public HttpResponseMessage Post(RideCordinate waypoints_)
        {
            // if state is not valid  method aborts the request and returns a Bad Request (400) status code
            if (!this.ModelState.IsValid)
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest));

            bool r = this.waypoints.AddWaypoints(waypoints_);

            var response = Request.CreateResponse(HttpStatusCode.Created, waypoints_);
            response.Headers.Add("Access-Control-Allow-Origin", "*");

            return response;
        }
        // PUT api/ridecordinates/5
        public HttpResponseMessage Put(RideCordinate waypoints__)
        {
            if (!this.ModelState.IsValid)
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest));

            if (waypoints__ == null)
                throw new HttpResponseException(this.Request.CreateResponse(HttpStatusCode.NotFound));

            bool result = this.waypoints.Edit(waypoints__);

            var response = Request.CreateResponse(HttpStatusCode.OK, result);
            response.Headers.Add("Access-Control-Allow-Origin", "*");
            return response;
        }
        public bool AddWaypoints(RideCordinate waypoints)
        {
            try
            {
                db.RideCordinates.Add(waypoints);
                db.SaveChanges();

               // return db.RideCordinates.Last().ride_id;
                return true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                //return 0;
                return false;
            }
        }
        public bool Edit(RideCordinate waypoint)
        {
            try
            {
                var ctx = HttpContext.Current;
                try
                {
                    if (ctx != null)
                    {
                        var currentData = ((List<RideCordinate>)ctx.Cache[CacheKey]).ToList();
                        RideCordinate waypoint_ = currentData.Find(p => p.ride_id == waypoint.ride_id );
                        currentData.Remove(waypoint_);
                        currentData.Add(waypoint);
                        ctx.Cache[CacheKey] = currentData.ToArray();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    return false;
                }

                db.Entry(waypoint).State = EntityState.Modified;
                db.SaveChanges();
                return true;

            }
            catch (System.Data.DataException ex)
            {

                // Shud do some logging
                Console.WriteLine(ex.ToString());
                //throw new System.Data.DataException();
                return false;
            }
        }
 public bool Edit(RideCordinate waypoint)
 {
     return waypoints_.Edit(waypoint);
 }
 public bool AddWaypoints(RideCordinate waypoints)
 {
     return waypoints_.AddWaypoints(waypoints);
 }