예제 #1
0
        protected IActionResult ReturnData <T>(T objectData, ActionStatus status = ActionStatus.Ok, List <String> messages = null)
        {
            var objectReturn = new Model.ResponseModel <T>()
            {
                DataObject = objectData,
                Status     = status.ToString(),
                Messages   = messages ?? new List <string>()
            };

            if (status == ActionStatus.Error)
            {
                return(this.NotFound(objectReturn));
            }
            if (status == ActionStatus.ValidationError)
            {
                return(this.NotFound(objectReturn));
            }
            if (status == ActionStatus.Warning)
            {
                return(this.NotFound(objectReturn));
            }
            else
            {
                return(Ok(objectReturn));
            }
        }
예제 #2
0
        protected Model.ResponseModel <T> ResponseModel <T>(T objectData, ActionStatus status = ActionStatus.Ok, List <String> messages = null)
        {
            var objectReturn = new Model.ResponseModel <T>()
            {
                DataObject = objectData,
                Status     = status.ToString(),
                Messages   = messages ?? new List <string>()
            };

            if (status == ActionStatus.Error)
            {
                this.Response.StatusCode = (int)HttpStatusCode.NotFound;
            }
            if (status == ActionStatus.ValidationError)
            {
                this.Response.StatusCode = (int)HttpStatusCode.NotFound;
            }
            if (status == ActionStatus.Warning)
            {
                this.Response.StatusCode = (int)HttpStatusCode.NotFound;
            }

            return(objectReturn);
        }