Exemplo n.º 1
0
        public async Task <bool> Delete(Guid id)
        {
            //TODO: minimize requested fields
            var endpoint = await FindById(id);

            if (endpoint == null)
            {
                return(false);
            }
            var deletionFilter = Builders <Endpoint> .Filter.Eq(nameof(Endpoint.Id), id);

            var result = await MongoCollection.DeleteOneAsync(deletionFilter);

            if (result.DeletedCount == 0)
            {
                return(false);
            }

            var fileFields = new List <(string, ObjectId)>()
            {
            };

            if (endpoint.OutputDataFileId != default)
            {
                fileFields.Add((nameof(Endpoint.OutputDataFileId), endpoint.OutputDataFileId));
            }
            if (endpoint.CallbackDataFileId != default)
            {
                fileFields.Add((nameof(Endpoint.CallbackDataFileId), endpoint.CallbackDataFileId));
            }

            await DeleteLinkedFiles(fileFields);

            return(true);
        }
Exemplo n.º 2
0
        public async Task <string> Delete(Guid id)
        {
            var linkedEndpoints = await EndpointService.FindLinkedByAuth(id);

            IEnumerable <Endpoint> endpoints = linkedEndpoints.ToArray();

            if (endpoints.Any())
            {
                return
                    ($"There are some endpoints which use that auth:\n{string.Join("\n", endpoints.Select(x => x.Path))}");
            }
            var deletionFilter = Builders <Auth> .Filter.Eq(nameof(Auth.Id), id);

            var result = await MongoCollection.DeleteOneAsync(deletionFilter);

            //TODO: remove that auth from all endpoints
            return(string.Empty);
        }
Exemplo n.º 3
0
 public static async void DeleteAsync(string id)
 {
     var objId = ObjectId.Parse(id);
     await MongoCollection.DeleteOneAsync(Builders <T> .Filter.Eq(x => x._id, objId));
 }
Exemplo n.º 4
0
 public static async void DeleteAsync(T obj)
 {
     await MongoCollection.DeleteOneAsync(Builders <T> .Filter.Eq(x => x._id, obj._id));
 }
 public async Task Delete(Expression <Func <T, bool> > filter)
 {
     await MongoCollection.DeleteOneAsync(filter);
 }
 public async Task Delete(T entity)
 {
     await MongoCollection.DeleteOneAsync(Builders <T> .Filter.Eq(e => e.Id, entity.Id));
 }
Exemplo n.º 7
0
 public async Task RemoveGame(CatanGame catanGame)
 {
     _logger?.LogDebug($"RemoveGame: {catanGame.Id}");
     await MongoCollection.DeleteOneAsync(game => game.Id == catanGame.Id);
 }
 public Task DeleteOne(Expression <Func <T, bool> > where)
 {
     return(MongoCollection.DeleteOneAsync(where));
 }
        public virtual async Task <bool> DeleteAsync(T entity)
        {
            var result = await MongoCollection.DeleteOneAsync(x => x.Equals(entity));

            return(result.IsAcknowledged);
        }
 public Task Delete(object key)
 {
     return(MongoCollection.DeleteOneAsync(FilterId(key)));
 }
Exemplo n.º 11
0
 public async Task DeleteAsync(Expression <Func <T, bool> > where)
 {
     await MongoCollection.DeleteOneAsync(where);
 }
Exemplo n.º 12
0
 public async Task DeleteAsync(T entity)
 {
     await MongoCollection.DeleteOneAsync(FilterId(entity.Id));
 }
Exemplo n.º 13
0
 public async Task DeleteAsync(object key)
 {
     await MongoCollection.DeleteOneAsync(FilterId(key));
 }
Exemplo n.º 14
0
 public async Task UnRegisterUser(Guid userId)
 {
     _logger?.LogDebug($"UnRegisterUser: {userId}");
     await MongoCollection.DeleteOneAsync(playerProfile => playerProfile.Id == userId);
 }
Exemplo n.º 15
0
 public async Task DeleteAsync(T obj)
 {
     await MongoCollection.DeleteOneAsync(Builders <T> .Filter.Eq(x => x.Id, obj.Id));
 }
Exemplo n.º 16
0
        /// <summary>
        /// Delete the entry with the passed id
        /// </summary>
        /// <param name="id"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public virtual async Task DeleteAsync(string id, CancellationToken cancellationToken = default(CancellationToken))
        {
            var filter = Builders <TImplementation> .Filter.Eq(o => o.Id, id);

            await MongoCollection.DeleteOneAsync(filter, cancellationToken);
        }
 public Task Delete(T entity)
 {
     return(MongoCollection.DeleteOneAsync(FilterId(entity.Id)));
 }