예제 #1
0
        protected ActionResult <T> ResponsePost <T>(string action, T result)
        {
            var route = GetActualRoute();


            if (!IsValidOperation())
            {
                return(BadRequest(new ValidationProblemDetails(_notifications.GetNotificationsErrorByKey())));
            }


            if (result == null)
            {
                return(NoContent());
            }


            var requestResponse = new RequestResponse <T>(result);


            //add all notifications of Error
            if (_notifications.HasNotificationsError())
            {
                var errors = _notifications.GetNotificationsError();
                foreach (var error in errors)
                {
                    requestResponse.AddMessageFailure(error.Value);
                }
            }

            //add all notifications of Success

            if (!_notifications.HasNotificationsSucess())
            {
                return(CreatedAtAction(action, route, requestResponse));
            }


            var msgs = _notifications.GetNotificationsSuccess();

            foreach (var msg in msgs)
            {
                requestResponse.AddMessageSucess(msg.Value);
            }


            return(CreatedAtAction(action, route, requestResponse));
        }