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()) })); }
public async Task <IViewComponentResult> InvokeAsync() { var notifications = await Task.FromResult(_notificator.GetNotifications()); notifications.ForEach(c => ViewData.ModelState.AddModelError(string.Empty, c.Message)); return(View()); }
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) })); }
protected ActionResult CustomResponse(object result = null) { if (IsValidOperation()) { return(Ok(new { result })); } return(BadRequest(new { Errors = Notificator.GetNotifications().Select(n => n.Message) })); }
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) })); }
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) })); }
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 })); }
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) })); }
protected List <string> GetErrors() { return(_notificator.GetNotifications().Select(n => n.Message).ToList()); }