Exemple #1
0
        public ActionResult <UserReadDto> CreateUser(UserCreateUpdateDto userCreateDto)
        {
            User model = _mapper.Map <User>(userCreateDto);

            _repository.CreateUser(model);
            _repository.SaveChanges();

            return(CreatedAtRoute(nameof(GetUserInfo), new { email = model.Email }, _mapper.Map <UserReadDto>(model)));
        }
Exemple #2
0
        public ActionResult PartialUpdateUser(string email, JsonPatchDocument <UserCreateUpdateDto> patchDocument)
        {
            User existingUser = _repository.GetUserInfo(email);
            UserCreateUpdateDto userToPatch = _mapper.Map <UserCreateUpdateDto>(existingUser);

            patchDocument.ApplyTo(userToPatch, ModelState);

            if (!TryValidateModel(userToPatch))
            {
                return(ValidationProblem(ModelState));
            }

            _mapper.Map(userToPatch, existingUser);
            _repository.SaveChanges();
            return(NoContent());
        }