Exemplo n.º 1
0
        protected IActionResult ResponseWithAllNotifications()
        {
            if (_domainNotification.HasNotifications())
            {
                return(BadRequest(_domainNotification.Notify()));
            }

            return(Ok());
        }
Exemplo n.º 2
0
 public IHttpActionResult Response(object result)
 {
     if (!_notifications.HasNotifications())
     {
         try
         {
             _unitOfWork.Commit();
             return(Ok(new
             {
                 success = true,
                 data = result
             }));
         }
         catch
         {
             // Logar o erro (Elmah)
             return(Content(HttpStatusCode.BadRequest, new
             {
                 success = false,
                 errors = new[] { "Ocorreu uma falha interna no servidor." }
             }));
         }
     }
     else
     {
         return(Content(HttpStatusCode.BadRequest, new
         {
             success = false,
             errors = _notifications.Notify().Select(n => n.Value)
         }));
     }
 }