コード例 #1
0
 public IActionResult Delete(int id)
 {
     if (!AuthorizeUser.isMatchID(User, id))
     {
         return(Forbid());
     }
     _userService.Delete(id);
     return(Ok());
 }
コード例 #2
0
        public IActionResult GetById(int id)
        {
            if (!AuthorizeUser.isMatchID(User, id) && !AuthorizeUser.isMatchRole(User, "admin"))
            {
                return(Forbid());
            }
            var user    = _userService.GetById(id);
            var userDto = _mapper.Map <UserResponse>(user);

            return(Ok(userDto));
        }
コード例 #3
0
 public IActionResult Update(int id, [FromBody] UserResource userDto)
 {
     if (!AuthorizeUser.isMatchID(User, id))
     {
         return(Forbid());
     }
     try
     {
         _userService.Update(id, userDto);
         return(Ok());
     }
     catch (AppException ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }