public async Task <JObject> Delete(string itemId) { try { var filter = Builders <Location> .Filter.Eq("_id", ObjectId.Parse(itemId)); DeleteResult result = await LocationCollection.DeleteOneAsync(filter); if (result.IsAcknowledged) { return (JObject.FromObject( new { status = "success", result = true, message = "Discount was deleted" } )); } else { return (JObject.FromObject( new { status = "false", result = false, message = "Location could not be deleted" } )); } } catch (Exception ex) { return (JObject.FromObject( new { status = "Exception Thrown", result = false, message = ex.Message } )); } }