public async Task <Pet> CreatePet(Pet pet) { //Load our specific table var petTable = Table.LoadTable(DynamoClient, "Pets"); //Set out uniq Id pet.PetId = new Random().Next(0, 1000000); // create the request to create the pet var queryRequest = PetRequestBuilder.Create(pet); // Save the changes await petTable.PutItemAsync(queryRequest); return(pet); }
public async Task <Pet> UpdatePet(Pet pet) { // Load our specific table var petTable = Table.LoadTable(DynamoClient, "Pets"); // get the owner var foundPet = await petTable.GetItemAsync(pet.PetId, pet.OwnerId); if (foundPet == null) { return(null); } // create the request to create the pet var queryRequest = PetRequestBuilder.Create(pet); // Save the changes var document = await petTable.UpdateItemAsync(queryRequest); return(pet); }