protected ValidationBase()
        {
            ContainerEvents containerEvents = new ContainerEvents();

            containerEvents.container = DomainEvent.Container.GetService <ICoreValidationHandler <CoreNotification> >();
            _notifications            = containerEvents.container;
        }
Example #2
0
        public async Task <IActionResult> Response(object result)
        {
            try
            {
                _notifications = DomainEvent.Container.GetService <ICoreValidationHandler <CoreNotification> >();
                if (_notifications != null)
                {
                    if (!_notifications.HasNotifications())
                    {
                        try
                        {
                            if (_uow != null)
                            {
                                _uow.Commit();
                            }

                            return(Ok(new
                            {
                                success = true,
                                data = result
                            }));
                        }
                        catch (Exception ex)
                        {
                            return(BadRequest(new
                            {
                                success = false,
                                errors = new[] { "Erro ao buscar dados do Servidor, EX:" + ex.Message }
                            }));
                        }
                    }
                    else
                    {
                        return(BadRequest(new
                        {
                            success = false,
                            errors = new[] { _notifications.GetNotify() }
                        }));
                    }
                }
                else
                {
                    return(BadRequest(new
                    {
                        success = false,
                        errors = new[] { "Erro ao buscar dados do Servidor" }
                    }));
                }
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new
                {
                    success = false,
                    errors = new[] { "Erro ao buscar dados do Servidor, EX:" + ex.Message }
                }));
            }
        }