public async Task <IActionResult> GetAuthorById(int id) { var author = await _authors.GetById(id, _cancellation); if (!author.HasValue) { return(NotFound()); } var editedNotes = await _notes.GetByAuthor(author.Value, _cancellation); return(new RestResult(AuthorDTO.FromAuthor(author.Value, editedNotes))); }
public async Task <IActionResult> Signup([FromBody] SignupDTO newAuthor) { if (newAuthor.UserName is null || newAuthor.GivenName is null || newAuthor.FamilyName is null || newAuthor.Email is null) { return(BadRequest()); } var input = new AuthorsRepository.AuthorInput( userName: newAuthor.UserName, givenName: newAuthor.GivenName, familyName: newAuthor.FamilyName, email: newAuthor.Email, birthDate: newAuthor.BirthDate); var author = await _authors.AddAuthor(input, _cancellation); var editedNotes = Enumerable.Empty <Shared.Models.Note>(); return(new RestResult(AuthorDTO.FromAuthor(author, editedNotes))); }