Пример #1
0
        protected ActionResult CustomResponse(object result = null, int http_code = 400)
        {
            if (ValidOperation())
            {
                return(Ok(new
                {
                    http_code = 200,
                    success = true,
                    return_time = DateTime.Now,
                    result = result
                }));
            }

            if (http_code == 404)
            {
                return(NotFound(new
                {
                    http_code = http_code,
                    success = false,
                    return_time = DateTime.Now,
                    notifications = _mapper.Map <List <NotificationViewModel> >(_notificator.GetNotifications())
                }));
            }

            return(BadRequest(new
            {
                http_code = http_code,
                success = false,
                return_time = DateTime.Now,
                notifications = _mapper.Map <List <NotificationViewModel> >(_notificator.GetNotifications())
            }));
        }
Пример #2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var notifications = await Task.FromResult(_notificator.GetNotifications());

            notifications.ForEach(c => ViewData.ModelState.AddModelError(string.Empty, c.Message));
            return(View());
        }
Пример #3
0
        protected ActionResult CustomResponse(object result = null)
        {
            if (ValidOperation())
            {
                return(Ok(new Response <object>(result)));
            }

            return(BadRequest(new Response <object> {
                Success = false,
                Errors = _notificator.GetNotifications().Select(n => n.Message).ToArray()
            }));
        }
        protected ActionResult CustomResponse(object result = null, int statusCode = StatusCodes.Status400BadRequest)
        {
            if (Success())
            {
                return(Ok(result));
            }

            return(BadRequest(new
            {
                Status = statusCode,
                Errors = _notificator.GetNotifications().Select(n => n.Message)
            }));
        }
Пример #5
0
        protected ActionResult CustomResponse(object result = null)
        {
            if (IsValidOperation())
            {
                return(Ok(new
                {
                    result
                }));
            }

            return(BadRequest(new
            {
                Errors = Notificator.GetNotifications().Select(n => n.Message)
            }));
        }
Пример #6
0
        protected ActionResult CustomResponse(object result = null)
        {
            if (OperacaoValida())
            {
                return(Ok(new
                {
                    success = true,
                    data = result
                }));
            }

            return(BadRequest(new
            {
                success = false,
                errors = _notificator.GetNotifications().Select(n => n.Mensagem)
            }));
        }
Пример #7
0
        protected ActionResult CustomResponse(object result = null)
        {
            if (!_notificator.HasNotification())
            {
                return(Ok(new
                {
                    success = true,
                    data = result
                }));
            }

            return(BadRequest(new
            {
                success = false,
                error = _notificator.GetNotifications().Select(n => n.Message)
            }));
        }
Пример #8
0
        protected IActionResult CustomResponse(object result = null)
        {
            if (!OperacaoValida())
            {
                return(BadRequest(new BadRequestCustomResponse
                {
                    Success = false,
                    Errors = _notificator.GetNotifications().Select(n => n.Message)
                }));
            }

            return(Ok(new OkCustomResponse <object>
            {
                Success = true,
                Data = result
            }));
        }
Пример #9
0
        protected ActionResult CustomResponse(object result = null)
        {
            if (IsValidaOperation())
            {
                return(Ok(new
                {
                    success = true,
                    data = result
                }));
            }
            ;

            return(BadRequest(new
            {
                success = false,
                errors = _notificator.GetNotifications().Select(x => x.Message)
            }));
        }
Пример #10
0
 protected List <string> GetErrors()
 {
     return(_notificator.GetNotifications().Select(n => n.Message).ToList());
 }