예제 #1
0
        //protected virtual ResponseDto PrepareCommonResponse<T1>(Action<T1> action, T1 param1)
        //{
        //    try
        //    {
        //        action.Invoke(param1);
        //        return ResponseCreator.CreateSuccessResponseDto();
        //    }
        //    catch (Exception e)
        //    {
        //        this.Log.Error(e);
        //        return ResponseCreator.CreateErrorResponseDto(EErrorCode.Unknow, e.Message);
        //    }
        //}

        //protected virtual ResponseDto PrepareCommonResponse<T1, T2>(Action<T1, T2> action, T1 param1, T2 param2)
        //{
        //    try
        //    {
        //        action.Invoke(param1, param2);
        //        return ResponseCreator.CreateSuccessResponseDto();
        //    }
        //    catch (Exception e)
        //    {
        //        this.Log.Error(e);
        //        return ResponseCreator.CreateErrorResponseDto(EErrorCode.Unknow, e.Message);
        //    }
        //}

        protected virtual ResponseWithDataDto <TResult> PrepareCommonResponseWithData <TResult>(Func <TResult> func)
        {
            try
            {
                TResult result = func.Invoke();
                return(ResponseCreator.CreateSuccessResponseWithDataDto(result));
            }
            catch (Exception e)
            {
                this.Log.Error(e);
                return(ResponseCreator.CreateErrorResponseWithDataDto <TResult>(EErrorCode.Unknow, e.Message));
            }
        }