public async Task <IActionResult> PutTarget(int id, TargetIM input)
        {
            if (id != input.Id)
            {
                return(BadRequest());
            }

            var target = _context.Targets.Find(id);

            target.Text  = input.Text;
            target.Color = ColorTranslator.FromHtml(input.Color);

            _context.Entry(target).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TargetExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutScale(int id, Scale scale)
        {
            if (id != scale.Id)
            {
                return(BadRequest());
            }

            _context.Entry(scale).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ScaleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutUser(Guid id, User newUser)
        {
            if (id != newUser.Id)
            {
                _logger.LogError("user record is not consistent, so cannot be updated", id);
                return(BadRequest());
            }

            var user = await _context.Users.FindAsync(id);

            if (user == null)
            {
                _logger.LogError("user not found", id);
                return(NotFound());
            }

            var isAdmin = await _authorizationService.AuthorizeAsync(User, "Administrator");

            if (!User.HasClaim(ClaimTypes.NameIdentifier, user.Id.ToString()) &&
                !isAdmin.Succeeded)
            {
                return(Unauthorized("only user himself or privileged user can edit user record"));
            }

            if (!isAdmin.Succeeded && user.LockedChange == true)
            {
                return(BadRequest("record is locked for change"));
            }

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                user.FirstName      = newUser.FirstName;
                user.MiddleName     = newUser.MiddleName;
                user.LastName       = newUser.LastName;
                user.Gender         = newUser.Gender;
                user.LockedChange   = newUser.LockedChange;
                user.LockedIcon     = newUser.LockedIcon;
                user.CanBeAuthor    = newUser.CanBeAuthor;
                user.CanBeEvaluator = newUser.CanBeEvaluator;
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    _logger.LogError("storing of updated user has failed", user);
                    throw;
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("storing of updated user has failed", ex, user);
                throw;
            }
            _logger.LogInformation("new user data stored", user);
            return(NoContent());
        }