Ejemplo n.º 1
0
        protected new IActionResult Response(Task task, object result, object validationMessage, object type = null)
        {
            if (IsValidOperation() && IsValidResponse(task))
            {
                if (validationMessage == null)
                {
                    validationMessage = _notifications.GetInformations().Select(n => n.Value);
                }

                return(Ok(new
                {
                    success = true,
                    informations = validationMessage,
                    data = result
                }));
            }
            else
            {
                var message = _notifications.GetErrors().Select(n => n.Value).Distinct();

                if (type == null)
                {
                    type = "error";
                }
                return(BadRequest(new
                {
                    success = false,
                    message = message.First(),
                    type = type
                }));
            }
        }