コード例 #1
0
        public async Task <ActionResult <UserReadDto> > CreateUser(UserCreateDto userCreateDto)
        {
            Response.Headers.Add("Access-Control-Allow-Origin", "*");

            await CheckUserExistsValidationErrors(userCreateDto);

            User userToCreate = await MapToBrisUser(userCreateDto);

            if (ModelState.ErrorCount > 0)
            {
                return(ValidationProblem(ModelState));
            }

            User user = await _repository.CreateUser(userToCreate);

            if (user == null)
            {
                return(Conflict());
            }
            var userReadDto = _mapper.Map <UserReadDto>(user);

            return(CreatedAtRoute(nameof(GetUserById), new { id = userReadDto.Id }, userReadDto));
        }