private void AddAuthor() { Console.WriteLine("Creating an author."); var name = _ioHelper.GetTextFromUser("Enter author name"); var surname = _ioHelper.GetTextFromUser("Enter author surname"); var bday = _ioHelper.GetDateTimeFromUser("Enter author's bday date"); while (bday > DateTime.Now.AddYears(-18)) { Console.WriteLine("Author is to young (18+). Try again..."); bday = _ioHelper.GetDateTimeFromUser("Enter author's bday date"); } var newAuthor = new Author { Name = name, Surname = surname, BirthDate = bday }; _authorsService.AddAsync(newAuthor).Wait(); Console.WriteLine("Author added successfully"); }
public async Task PostAuthor([FromBody] Author author) { await _authorsService.AddAsync(author); }