Exemple #1
0
        /// <summary>
        /// place/update
        /// </summary>
        /// <param name="request">Request.</param>
        public PlaceUpdateResponse Put(PlaceCreateUpdateRequest request)
        {
            PlaceUpdateResponse response = new PlaceUpdateResponse ();

            PlaceResponse place = new PlaceResponse ();
            place.Id = request.Id;
            GeoJson2DGeographicCoordinates loc = new GeoJson2DGeographicCoordinates (request.longitude, request.latitude);
            place.loc = loc;
            place.name = request.name;
            place.radius = request.radius;

            var query = Query.EQ ("_id", request.Id);
            var update = Update.Replace (place);
            FindAndModifyResult result = placescollection.FindAndModify (query, SortBy.Null, update);

            response.Id = request.Id;
            response.loc = loc;
            response.name = request.name;
            response.radius = request.radius;
            response.responseStatus = new ResponseStatus ();
            if (result.Ok) {
                response.responseStatus.ErrorCode = "200";
                response.responseStatus.Message = "SUCCESS";
            } else {
                response.responseStatus.ErrorCode = "500";
                response.responseStatus.Message = "FAILURE";

            }
            return response;
        }
Exemple #2
0
        /// <summary>
        /// place/create
        /// </summary>
        /// <param name="request">Request.</param>
        public PlaceCreateResponse Post(PlaceCreateUpdateRequest request)
        {
            PlaceCreateResponse response1 = new PlaceCreateResponse ();
            PlaceResponse response2 = new PlaceResponse ();

            response2.loc = new GeoJson2DGeographicCoordinates (request.longitude, request.latitude);
            response2.name = request.name;
            response2.radius = request.radius;

            WriteConcernResult result = placescollection.Insert (response2);

            response1.Id = response2.Id;
            response1.responseStatus = new ResponseStatus ();

            if (result.Ok) {
                response1.responseStatus.ErrorCode = "200";
                response1.responseStatus.Message = "SUCCESS";
            } else {
                response1.responseStatus.ErrorCode = "500";
                response1.responseStatus.Message = "FAILURE";
            }

            return response1;
        }