Example #1
0
        public Response <Role> GetRoleInfo(GetObjectByIDRequest request)
        {
            Response <Role> response = new Response <Role>();

            if (request == null || request.ID == 0)
            {
                ArgumentNullException ex = new ArgumentNullException("GetRoleByID request");
                LogError(ex);
                response.ErrorCode = ErrorCode.Argument;
                response.Exception = ex;
                return(response);
            }

            try
            {
                RoleAccessor accessor = new RoleAccessor();
                response.Result    = accessor.GetRoleByID(request.ID);
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.IsSuccess = false;
                response.ErrorCode = ErrorCode.Technical;
            }

            return(response);
        }
Example #2
0
        public Response <User> GetUserInfo(GetObjectByIDRequest request)
        {
            Response <User> response = new Response <User>();

            if (request == null || request.ID == 0)
            {
                ArgumentNullException ex = new ArgumentNullException("GetUserInfo request");
                LogError(ex);
                response.ErrorCode = ErrorCode.Argument;
                response.Exception = ex;
                return(response);
            }

            try
            {
                UserAccessor accessor = new UserAccessor();
                response.Result = accessor.GetUserById(request.ID);
                if (response.Result == null)
                {
                    response.IsSuccess = false;
                    response.ErrorCode = ErrorCode.DataEffective;
                }
                else
                {
                    response.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.IsSuccess = false;
                response.ErrorCode = ErrorCode.Technical;
            }

            return(response);
        }