public async Task <Author> CreateAsync(Author entity) { var input = new AuthorsRepository.AuthorInput( userName: entity.UserName, givenName: entity.GivenName, familyName: entity.FamilyName, email: entity.Email, birthDate: entity.BirthDate); var addedAuthor = await _authors.AddAuthor(input); return(Author.FromAuthor(addedAuthor)); }
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))); }
public async ValueTask <SignupResponse> Handle(SignupRequest request, ServerCallContext ctx) { if (string.IsNullOrEmpty(request.UserName)) { throw new ArgumentNullRpcException("user_name"); } if (string.IsNullOrEmpty(request.GivenName)) { throw new ArgumentNullRpcException("given_name"); } if (string.IsNullOrEmpty(request.FamilyName)) { throw new ArgumentNullRpcException("famly_name"); } if (string.IsNullOrEmpty(request.Email)) { throw new ArgumentNullRpcException("email"); } var input = new AuthorsRepository.AuthorInput( userName: request.UserName, givenName: request.GivenName, familyName: request.FamilyName, email: request.Email, birthDate: request.Birthdate?.ToDateTime()); var createdAuthor = await _authors.AddAuthor(input, ctx.CancellationToken); return(new SignupResponse() { CreatedAuthor = ModelMapper.MapAuthor(createdAuthor) }); }