コード例 #1
0
        public ActionResult ModifyUserRole([FromBody] UpdateGuildMemberPayload payload)
        {
            var userGuild = _repository.GetGuildUser(payload.GuildId, payload.UserId);

            if (userGuild == null)
            {
                return(NotFound());
            }

            var userGuildToPatch = _mapper.Map <UserGuildRequestUpdateDto>(userGuild);

            payload.PatchDocument.ApplyTo(userGuildToPatch, ModelState);
            if (!TryValidateModel(userGuildToPatch))
            {
                return(ValidationProblem(ModelState));
            }

            _mapper.Map(userGuildToPatch, userGuild);
            _repository.UpdateUserGuild(userGuild);
            _repository.SaveChanges();
            return(NoContent());
        }