Exemple #1
0
        public async Task <int> UpdateUserAsync(int id, UpdatedUserRq model, UserIdentity <int> issuer)
        {
            var user = await _userManagement.FindByIdAsync(id.ToString());

            _mapper.Map(model, user);

            user.UpdateBy(issuer);
            await _userManagement.UpdateAsync(user);

            await _uow.SaveChangesAsync();

            return(user.Id);
        }
Exemple #2
0
        public async Task <IActionResult> UpdateUserAsync(int id, [FromBody] UpdatedUserRq model)
        {
            if (!ModelState.IsValid)
            {
                Microsoft.AspNetCore.Mvc.ModelBinding.ModelErrorCollection modelErrors = new Microsoft.AspNetCore.Mvc.ModelBinding.ModelErrorCollection();
                foreach (var entry in ModelState.Values)
                {
                    foreach (var error in entry.Errors)
                    {
                        modelErrors.Add(error);
                    }
                }
                return(BadRequest(modelErrors));
            }
            var userId = await _userService.UpdateUserAsync(id, model, GetCurrentUserIdentity <int>());

            return(OkValueObject(userId));
        }