Ejemplo n.º 1
0
        public async Task <APIResponse> DeleteRecordById(string collectionName, string id)
        {
            _logger.LogInformation($"DeleteRecordById request recieved");

            var collection = await GetCollection(collectionName).ConfigureAwait(false);

            if (collection == null)
            {
                return(APIResponse.NotOk(Request.ToRequestString(), $"Cant find collection with name {collectionName}", HttpStatusCode.BadRequest));
            }

            var response = await _elasticBand.Delete(collection.Index, id).ConfigureAwait(false);

            if (response.Ok)
            {
                return new APIResponse
                       {
                           Request = Request.ToRequestString(),
                           Ok      = true,
                           Result  = "deleted",
                           Data    = id
                       }
            }
            ;

            return(APIResponse.NotOk(Request.ToRequestString(), "Failed to delete record", HttpStatusCode.NotFound));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Delete an object.
 /// </summary>
 /// <param name="id">A string containing the id of the object to delete.</param>
 /// <returns>An ElasticBandResponse</returns>
 public async Task <ElasticBandResponse> Delete(string id)
 {
     return(await _elasticBand.Delete(IndexName, id));
 }