Esempio n. 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));
        }
Esempio n. 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));
        }