public static void Main() { var factory = new PhonebookFactory(); var data = new PhonebookRepository(factory); var engine = new Engine(data); engine.Run(); }
public async Task <IActionResult> Post([FromRoute] string name) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var phonebook = PhonebookFactory.Create(); phonebook.Name = name; phonebookRepository.Add(phonebook); await phonebookRepository.Commit(); return(Ok()); }
public void SetUp() { client = new Client(ConfigurationManager.AppSettings["username"]); client.SetPasswordHash(ConfigurationManager.AppSettings["password"]); proxy = new ProxyHTTP(ConfigurationManager.AppSettings["baseUrl"]); smsFactory = new SMSFactory(client, proxy); senderFactory = new SenderFactory(client, proxy); userFactory = new UserFactory(client, proxy); contactsFactory = new ContactsFactory(client, proxy); var clientLegacy = new Client(ConfigurationManager.AppSettings["usernameOldPhonebook"]); clientLegacy.SetPasswordHash(ConfigurationManager.AppSettings["passwordOldPhonebook"]); phonebookFactory = new PhonebookFactory(clientLegacy, proxy); subUserName = ConfigurationManager.AppSettings["subUserName"]; validTestNumber = ConfigurationManager.AppSettings["validTestNumber"]; }
public void Setup() { //InMemory DB did not catch violation of foreign key constraint due to incorrect context configuration options = new DbContextOptionsBuilder <AbsaPhonebookContext>().UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=AbsaPhonebook;Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False").Options; //"Data Source=(local);Initial Catalog=AbsaPhonebook;Integrated Security=True;" - MSSQL connection string var context = new AbsaPhonebookContext(options); context.RemoveRange(context.Phonebook); context.RemoveRange(context.PhonebookEntry); context.SaveChanges(); phonebook = PhonebookFactory.Create(); phonebook.Name = "Stellenbosch Directory"; phonebook.PhonebookEntries.Add(CreateEntry(phonebook, "Dave Worthington", "021979452")); phonebook.PhonebookEntries.Add(CreateEntry(phonebook, "Bill Lumsden", "0215554334")); repository = new PhonebookRepository(context); entryRepository = new PhonebookEntryRepository(context); repository.Add(phonebook); repository.Commit(); }
public void Setup() { options = new DbContextOptionsBuilder <AbsaPhonebookContext>().UseInMemoryDatabase(databaseName: "AbsaPhonebook").Options; var context = new AbsaPhonebookContext(options); context.RemoveRange(context.Phonebook); context.RemoveRange(context.PhonebookEntry); context.SaveChanges(); phonebook = PhonebookFactory.Create(); phonebook.Name = "Stellenbosch Directory"; phonebook.PhonebookEntries.Add(CreateEntry(phonebook, "Dave Worthington", "021979452")); phonebookEntry = CreateEntry(phonebook, "Bill Lumsden", "0215554334"); phonebook.PhonebookEntries.Add(phonebookEntry); repository = new PhonebookRepository(context); entryRepository = new PhonebookEntryRepository(context); repository.Add(phonebook); repository.Commit(); controller = new PhonebookController(repository, entryRepository); }
public async Task <IActionResult> Put([FromRoute] Guid id, [FromBody] PhonebookDTO value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var phonebook = await phonebookRepository.GetById(id); if (phonebook == null) { return(NotFound()); } var updatedBook = PhonebookFactory.Create(); updatedBook.Name = value.Name; value.SetID(updatedBook); phonebookRepository.Update(updatedBook); await phonebookRepository.Commit(); return(NoContent()); }