예제 #1
0
        public static ActionResult AsActionResultSafeVariant(this IResult obj)
        {
            var result = new ApiSafeResult()
            {
                IsSuccessful = obj.IsSuccessful,
                Error        = obj.IsSuccessful ? null : new ApiErrorResult {
                    Code = obj.ErrorCode, Message = obj.ErrorMessage
                }
            };

            return(new ObjectResult(result));
        }
예제 #2
0
        public static ActionResult AsActionResultSafeVariant <T>(this IResult <T> obj)
        {
            var result = new ApiSafeResult <T>();

            if (obj.IsSuccessful)
            {
                result.IsSuccessful = true;

                result.Result = obj.Value;
            }
            else
            {
                result.Error = new ApiErrorResult {
                    Code = obj.ErrorCode, Message = obj.ErrorMessage
                };
            }
            return(new ObjectResult(result));
        }