public async Task <IActionResult> PartialUpdateGroup(int id,
                                                             [FromBody] JsonPatchDocument <GroupForUpdate> model)
        {
            _logger.LogInformation("Partial update group, id: {id}", id);

            var groupFromDb = await _groupRepository.GetByIdAsync(id);

            if (groupFromDb == null)
            {
                return(BadRequest("No group found for this id"));
            }

            var groupToPatch = _jsonPatchManager.Convert(model, groupFromDb);

            if (!TryValidateModel(groupToPatch))
            {
                return(new UnprocessableEntityObjectResult(ModelState));
            }

            _mapper.Map(groupToPatch, groupFromDb);

            await _groupService.UpdateGroup(groupFromDb);

            return(NoContent());
        }
        public async Task <IActionResult> PartialUpdateAccount(int id,
                                                               [FromBody] JsonPatchDocument <AccountForUpdate> model)
        {
            _logger.LogInformation("Partial update account, id: {id}", id);

            var accountFromDb = await _accountRepository.GetByIdAsync(id);

            if (accountFromDb == null)
            {
                return(BadRequest("No account found for this id"));
            }

            var userEmail = User.Claims.FirstOrDefault(s => s.Type == JwtClaimTypes.Email).Value;
            var userRole  = User.Claims.FirstOrDefault(s => s.Type == JwtClaimTypes.Role).Value;

            if (userEmail != accountFromDb.Email && userRole != "admin")
            {
                return(Forbid());
            }

            var accountToPatch = _jsonPatchManager.Convert(model, accountFromDb);

            if (!TryValidateModel(accountToPatch))
            {
                return(new UnprocessableEntityObjectResult(ModelState));
            }

            _mapper.Map(accountToPatch, accountFromDb);

            await _accountService.UpdateAccount(accountFromDb);

            return(NoContent());
        }