public async Task <Transaction> GetByIdAsync(Identificator id, CancellationToken token = default) => await( await( await _bundle.TransactionRepository.Collection .FindAsync(s => s.Id == id.ToString())) .FirstOrDefaultAsync()) .ToEntityAsync(_transactionTypeRepository, token);
public async Task <bool> DeleteAsync(Identificator id, CancellationToken token = default) { var curItem = await GetByIdAsync(id, token); var deleteResult = await _bundle.TransactionRepository.Collection.DeleteOneAsync( new ExpressionFilterDefinition <TransactionDTO>(s => s.Id == id.ToString()), token); return(deleteResult.IsAcknowledged && (deleteResult.DeletedCount == 1)); }
public string Check(List <string> arguments) { string id = arguments[0]; Identificator element = (Identificator)this.harvesters.FirstOrDefault(x => x.Id == id) ?? this.providers.FirstOrDefault(p => p.Id == id); if (element != null) { return(element.ToString()); } return($"No element found with id - {id}"); }
public async Task <bool> DeleteAsync(Identificator id, CancellationToken token = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } var deleteResult = await _collection.DeleteOneAsync( new ExpressionFilterDefinition <FundDTO>(s => s.Id == id.ToString()), token); return(deleteResult.IsAcknowledged && (deleteResult.DeletedCount == 1)); }
public async Task <Fund> GetByIdAsync(Identificator id, CancellationToken token = default) { if (id == null) { throw new ArgumentNullException(nameof(id)); } var foundResult = await( await _collection .FindAsync(s => s.Id == id.ToString())) .FirstOrDefaultAsync(); return(foundResult == null ? null : await foundResult?.ToEntityAsync(_transactionRepository, token)); }
public async Task <bool> IsExistById(Identificator id, CancellationToken token = default) => (await _collection.CountDocumentsAsync(s => s.Id == id.ToString())) != 0;