public async Task <int> Put(DomainModels.PhoneBook entity) { var phonebook = await _context.PhoneBooks.FindAsync(entity.Id); _context.Entry(phonebook).CurrentValues.SetValues(entity); return(1); }
public async Task TestMissingRequiredNameShouldThrowException() { var phonebook = new DomainModels.PhoneBook(); await _repo.Post(phonebook); Assert.Throws <DbUpdateException>(() => dbContext.SaveChanges()); }
public async Task TestInsertedEntityShouldContainGeneratedId() { var phonebook = new DomainModels.PhoneBook { Name = "Book 1" }; await _repo.Post(phonebook); await dbContext.SaveChangesAsync(); Assert.NotNull(phonebook.Id); }
public async Task TestInsertedEntityShouldContainGeneratedId() { var phonebook = new DomainModels.PhoneBook { Name = "Book 1" }; await _phoneBookRepo.Post(phonebook); await dbContext.SaveChangesAsync(); var phonebookentry = new PhoneBookEntry { Name = "Eric", PhoneBookId = phonebook.Id, PhoneNumber = "0827074282" }; await _phoneBookEntryRepo.Post(phonebookentry); await dbContext.SaveChangesAsync(); Assert.NotNull(phonebookentry.Id); }
public async Task <int> Post(DomainModels.PhoneBook entity) { await _context.PhoneBooks.AddAsync(entity); return(1); }