예제 #1
0
        public UserDeletedReturnDto DeleteUserById(int userId)
        {
            if (!_userOperations.UserExists(userId))
            {
                return(null);
            }
            var user = _userOperations.GetUserById(userId);

            if (_userOperations.UserIsManager(user))
            {
                _departmentOperations.RemoveManager(user.Department);
            }
            var userDeleted = _userOperations.DeleteUser(user);

            return(userDeleted == null ? null : Mapper.Map <UserDeletedReturnDto>(userDeleted));
        }
예제 #2
0
 public HttpResponseMessage Delete(int id)
 {
     try
     {
         _operations.DeleteUser(id);
         return(new HttpResponseMessage()
         {
             StatusCode = HttpStatusCode.OK,
             Content = new StringContent($"User {id} deleted")
         });
     }
     catch (Exception ex)
     {
         return(new HttpResponseMessage()
         {
             StatusCode = HttpStatusCode.InternalServerError,
         });
     }
 }