public void Delete(UserFilter filterData) { if (filterData == null || !filterData.HasFilter()) throw new ArgumentException("Invalid filter data"); var query = GetUserQuery(filterData) ?? new BsonDocument(); var mongoDb = MongoDb.OpenConnection(); var collection = mongoDb.GetCollection<BsonDocument>(CollectionsEnum.users.ToString()); var result = collection.DeleteMany(query); if (result.DeletedCount == 0) throw new Exception("There aren't any users with the criteria provided"); }
public void Delete(UserFilter filterData) { if (filterData == null || !filterData.HasFilter()) { throw new ArgumentException("Invalid filter data"); } var query = GetUserQuery(filterData) ?? new BsonDocument(); var mongoDb = MongoDb.OpenConnection(); var collection = mongoDb.GetCollection <BsonDocument>(CollectionsEnum.users.ToString()); var result = collection.DeleteMany(query); if (result.DeletedCount == 0) { throw new Exception("There aren't any users with the criteria provided"); } }