Exemplo n.º 1
0
        public async Task <IActionResult> CreateAuthor(ApiAuthorForCreate author)
        {
            try
            {
                //var subject = User.Claims.FirstOrDefault(c => c.Type == "sub")?.Value;
                //if (string.IsNullOrEmpty(subject))
                //{
                //    return BadRequest();
                //}

                //if (_authorManager.AuthorExists(subject))
                //{
                //    return BadRequest();
                //}

                var usr = _mapper.Map <ApiAuthorForCreate, Author>(author);
                usr.IsActivated = true;
                var newAuthor = await _authorManager.CreateAsync(usr);

                if (newAuthor == null)
                {
                    return(BadRequest(new ApiBadRequestResponse("null author found")));
                }

                return(Created("", newAuthor));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Exemplo n.º 2
0
 public async Task CreateAsync(DtoAuthorInput input)
 {
     var @author = Author.Create(AbpSession.GetTenantId(), input.FirstName, input.LastName, input.Email);
     await _authorManager.CreateAsync(@author);
 }