public async Task DeleteGame(string gameId, ArmamentType playerId) { // NOTE: possible better solutions, but delete player when the player exits game, // if no more players exist, then delete game; checking on game load for // stale games would require a full table load, which would kill our // buffer on free data. await _context.DeleteAsync <PlayerDTO>(gameId, playerId); if ((await RequestPlayerList(gameId)).Count == 0) { await _context.DeleteAsync <GameDTO>(gameId); } }
/// <summary> /// A Lambda function to respond to HTTP Delete methods from API Gateway /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public async Task <APIGatewayProxyResponse> Delete(APIGatewayProxyRequest request, ILambdaContext context) { var id = string.Empty; if (request.PathParameters != null && request.PathParameters.ContainsKey(Functions.QueryParameterId)) { id = request.PathParameters[Functions.QueryParameterId]; } else if (request.QueryStringParameters != null && request.QueryStringParameters.ContainsKey(Functions.QueryParameterId)) { id = request.QueryStringParameters[Functions.QueryParameterId]; } if (string.IsNullOrWhiteSpace(id)) { throw new ApplicationException($"{nameof(id)} cannot be null or empty."); } context.Logger.LogLine($"Deleting todo item with id {id}"); await _dbContext.DeleteAsync <TodoItem>(id); return(new APIGatewayProxyResponse() { StatusCode = (int)HttpStatusCode.OK, Headers = Functions.LambdaHeader }); }
public Task Delete(string id) { UpdateTableTracker(); var task = _context.DeleteAsync <T>(id); return(task); }
public async Task Delete(string id) { var tag = (await Get(id)) .ThrowObjectNotFoundExceptionIfNull(); await _context.DeleteAsync(tag); }
public async Task Delete(string id) { if (String.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException("id"); } await _context.DeleteAsync <TokenUser>(id); }
public async Task Delete(string id) { var user = (await Get(id)) .ThrowObjectNotFoundExceptionIfNull(); // TODO: delete all rights await _context.DeleteAsync(user); }
public async Task RevokeAsync(TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } cancellationToken.ThrowIfCancellationRequested(); await _context.DeleteAsync(authorization, cancellationToken); }
public async Task Revoke(TCode code, CancellationToken cancellationToken) { if (code == null) { throw new ArgumentNullException(nameof(code)); } cancellationToken.ThrowIfCancellationRequested(); await _context.DeleteAsync <TCode>(code, cancellationToken); }
public static async Task <IEnumerable <T> > Delete <T>( this IDynamoDBContext context, List <ScanCondition> scanConditions) where T : class { // TODO: learn about batch write that can take deletes // until then get the list to delete and then delete individually var ids = (await context.Where <T>(scanConditions)).ToList(); await Task.WhenAll(ids.Select(id => context.DeleteAsync(id))); return(ids); }
private List <NoteDb> UpsertNotes(Guid targetId, int count) { var notes = new List <NoteDb>(); var random = new Random(); Func <DateTime> funcDT = () => DateTime.UtcNow.AddDays(0 - random.Next(100)); notes.AddRange(_fixture.Build <NoteDb>() .With(x => x.CreatedAt, funcDT) .With(x => x.TargetType, TargetType.person) .With(x => x.TargetId, targetId) .CreateMany(count)); foreach (var note in notes) { _dynamoDb.SaveAsync(note).GetAwaiter().GetResult(); _cleanup.Add(async() => await _dynamoDb.DeleteAsync(note, default).ConfigureAwait(false)); } return(notes); }
protected virtual void Dispose(bool disposing) { if (disposing && !_disposed) { if (null != Person) { _dbContext.DeleteAsync <PersonDbEntity>(Person.Id).GetAwaiter().GetResult(); } _disposed = true; } }
public async Task <bool> DeleteAsync(City city) { try { await dynamoContext.DeleteAsync(city); return(true); } catch (Exception) { return(false); } }
public async Task RemoveConnectionAsync(string connectionId) { var connection = (await _context.QueryAsync <SocketConnection>(connectionId).GetRemainingAsync()).SingleOrDefault(); if (connection == null) { throw new NullReferenceException($"Could not remove connectionId: {connectionId}. Socket Connection not found"); } // await _context.DeleteAsync<SocketConnection>(connectionId); await _context.DeleteAsync(connection); return; }
public static async Task PerformCRUDOperations(IDynamoDBContext context) { int bookId = 1001; // Some unique value. Book myBook = new Book { Id = bookId, Title = "object persistence-AWS SDK for.NET SDK-Book 1001", Isbn = "111-1111111001", BookAuthors = new List <string> { "Author 1", "Author 2" }, }; // Save the book to the ProductCatalog table. await context.SaveAsync(myBook); // Retrieve the book from the ProductCatalog table. Book bookRetrieved = await context.LoadAsync <Book>(bookId); // Update some properties. bookRetrieved.Isbn = "222-2222221001"; // Update existing authors list with the following values. bookRetrieved.BookAuthors = new List <string> { " Author 1", "Author x" }; await context.SaveAsync(bookRetrieved); // Retrieve the updated book. This time, add the optional // ConsistentRead parameter using DynamoDBContextConfig object. await context.LoadAsync <Book>(bookId, new DynamoDBContextConfig { ConsistentRead = true, }); // Delete the book. await context.DeleteAsync <Book>(bookId); // Try to retrieve deleted book. It should return null. Book deletedBook = await context.LoadAsync <Book>(bookId, new DynamoDBContextConfig { ConsistentRead = true, }); if (deletedBook == null) { Console.WriteLine("Book is deleted"); } }
protected virtual void Dispose(bool disposing) { if (disposing && !_disposed) { if (Notes.Any()) { foreach (var note in Notes) { _dbContext.DeleteAsync(note).GetAwaiter().GetResult(); } } _disposed = true; } }
protected virtual void Dispose(bool disposing) { if (disposing && !_disposed) { if (Contacts.Any()) { foreach (var contact in Contacts) { _dbContext.DeleteAsync(contact).GetAwaiter().GetResult(); } } _disposed = true; } }
public async Task RemoveFromRoleAsync(TUser user, string normalisedRoleName, CancellationToken cancellationToken) { if (user == null) { throw new ArgumentNullException(nameof(user)); } cancellationToken.ThrowIfCancellationRequested(); var roleUsers = await QueryRoleUsers(normalisedRoleName, user.Id, cancellationToken); foreach (var roleUser in roleUsers) { await _context.DeleteAsync(roleUser, cancellationToken); } }
public static async void TestCrudOperations(IDynamoDBContext context) { int bookId = 1001; // Some unique value. Book myBook = new Book { Id = bookId, Title = "object persistence-AWS SDK for.NET SDK-Book 1001", Isbn = "111-1111111001", BookAuthors = new List <string> { "Author 1", "Author 2" }, }; // Save the book. await context.SaveAsync(myBook); // Retrieve the book. Book bookRetrieved = await context.LoadAsync <Book>(bookId); // Update few properties. bookRetrieved.Isbn = "222-2222221001"; bookRetrieved.BookAuthors = new List <string> { " Author 1", "Author x" }; // Replace existing authors list with this. await context.SaveAsync(bookRetrieved); // Retrieve the updated book. This time add the optional ConsistentRead parameter using DynamoDBContextConfig object. await context.LoadAsync <Book>(bookId, new DynamoDBContextConfig { ConsistentRead = true }); // Delete the book. await context.DeleteAsync <Book>(bookId); // Try to retrieve deleted book. It should return null. Book deletedBook = await context.LoadAsync <Book>(bookId, new DynamoDBContextConfig { ConsistentRead = true }); if (deletedBook == null) { Console.WriteLine("Book is deleted"); } }
/// <summary> /// Delete a todo. /// </summary> /// <remarks> /// Currently a simple implementation for a list/item structure. If the todo is a list then delete it /// and all its children other just delete itself because it is an item. /// </remarks> public async Task Delete(string id) { var todo = (await Get(id)) .ThrowObjectNotFoundExceptionIfNull(); if (todo.Type.Equals(TodoType.List)) { await DeleteByParent(id); } if (todo.Tags.IsNotNull()) { await Task.WhenAll(todo.Tags.Select(RemoveRightForTag)); } await _userRightStore.RemoveRight(_creatorId, id); await _context.DeleteAsync(todo); }
public async Task Confirm(ConfirmAdvertModel model) { //using (var context = new DynamoDBContext(_amazonDynamoDB)) //{ var record = await _dynamoDBContext.LoadAsync <AdvertDbModel>(model.Id); if (record == null) { throw new KeyNotFoundException($"A record with ID={model.Id} was not found."); } if (model.AdvertStatus == AdvertStatus.Active) { record.AdvertStatus = AdvertStatus.Active; await _dynamoDBContext.SaveAsync(record); } else { await _dynamoDBContext.DeleteAsync(record); } //} }
public void ARecordExists(string name, IDictionary <string, string> parameters) { string id = null; if (parameters.ContainsKey("id")) { id = parameters["id"]; } else { id = name.Split(':')?.Last(); } if (!string.IsNullOrEmpty(id)) { var testPerson = _fixture.Build <PersonDbEntity>() .With(x => x.Id, Guid.Parse(id)) .With(x => x.VersionNumber, (int?)null) .Create(); _dynamoDbContext.SaveAsync <PersonDbEntity>(testPerson).GetAwaiter().GetResult(); _cleanup.Add(async() => await _dynamoDbContext.DeleteAsync <PersonDbEntity>(testPerson).ConfigureAwait(false)); } }
public async Task <bool> setData(DataStore newDataStore) { DataStore retrievedValue = await context.LoadAsync <DataStore>(newDataStore.UserName); if (retrievedValue != null) { await context.DeleteAsync <DataStore>(newDataStore.UserName); } await context.SaveAsync(newDataStore); return(true); //var existingData = myCachedData.Find(x => x.accountInformation.userName == newDataStore.accountInformation.userName); //if (existingData == null) //{ // myCachedData.Add(newDataStore); //} //else //{ // //Not a good way of doing this. It would be better to manipulate the already inserted objects, but this is quicker. // myCachedData.Remove(existingData); // myCachedData.Add(newDataStore); //} }
public Task DeleteShowAsync(string id) { return(_context.DeleteAsync <Show>(id)); }
public async Task Delete(string id) { await _context.DeleteAsync <T>(id); }
public void Remove(string key) { _dynamoDbContext.DeleteAsync <T>(key).GetAwaiter().GetResult(); }
public async Task Delete(string isbn) { await _dbContext.DeleteAsync <RepositoryBook>(isbn); }
public async Task Delete <K, T>(K key) { await dbContext.DeleteAsync <T>(key); }
public async Task DeleteEntityAsync(string Artist, string SongTitle) { await DDBContext.DeleteAsync <Music>(Artist, SongTitle); }
public Task Delete(Guid id) => ddbContext.DeleteAsync <LinkDto>(id);
public async Task <ServiceResult> DeleteItem(string partitionKey) { await _dynamoDbContext.DeleteAsync <TDataType>(partitionKey); return(ServiceResult.Succeeded()); }