コード例 #1
0
        /// <summary>
        /// Processamento do Serviço
        /// </summary>
        public int IniciarProcessamento(Agendamento agendamento)
        {
            try
            {
                if (agendamento == null)
                {
                    Console.Write("Erro, não foi encontrada nenhuma tarefa agendada");
                    return(2);
                }

                var bloqueio = ConsultarBloqueioComSTSNull(agendamento);

                if (bloqueio != null && bloqueio.STS == null)
                {
                    AtualizarBloqueio(bloqueio, 'P');

                    var gerouLog = GerarArquivo(agendamento, bloqueio.UNIQUE_ID);

                    if (gerouLog)
                    {
                        AtualizarBloqueio(bloqueio, 'F');
                        AtualizarAgendamentos(agendamento, EnumClass.STS.executado, MSG.executado);
                        //executado
                        return(0);
                    }
                    else
                    {
                        AtualizarBloqueio(bloqueio, null);
                        var erros = _notificationHandler.GetNotifications();
                        AtualizarAgendamentos(agendamento, EnumClass.STS.erro, string.Join(",", erros));
                        //erro
                        return(2);
                    }
                }
                else
                {
                    AtualizarAgendamentos(agendamento, EnumClass.STS.sem_dados, MSG.sem_dados);
                    //sem dados(não existe IDs com STS=null)
                    return(1);
                }
            }
            catch (Exception ex)
            {
                var erros = _notificationHandler.GetNotifications();
                AtualizarAgendamentos(agendamento, EnumClass.STS.erro, string.Join(",", erros));
                //erro
                return(2);
            }
        }
コード例 #2
0
ファイル: LeadService.cs プロジェクト: rmstreet/RedSpark.Thot
        public LeadDetailsModel Creation(LeadCreateModel leadModel)
        {
            // TODO: Resolve Usuario atual(Logado)
            var userId = 1;

            leadModel.CreatedById = userId;

            var lead = _mapper.Map <Lead>(leadModel);

            // TODO: Validator
            _leadValidator.Creation(lead);

            // TODO: Chama repository
            var leadRepository = _unitOfWork.GetRepository <ILeadRepository>();
            var leadCreated    = leadRepository.Create(lead);

            LeadDetailsModel leadDetailsModel = new LeadDetailsModel();

            // TODO: Commit
            if (!_unitOfWork.Commit())
            {
                leadDetailsModel.Erros = _mapper.Map <List <ErroModel> >(_notificationHandler.GetNotifications());
                return(leadDetailsModel);
            }

            // TODO: Devolver objeto sucesso ou falha
            leadDetailsModel = _mapper.Map <LeadDetailsModel>(lead);

            return(leadDetailsModel);
        }
コード例 #3
0
 protected IActionResult ResponseInvalid()
 {
     return(BadRequest(new
     {
         Messages = _notifications.GetNotifications().Select(x => x.Value)
     }));
 }
コード例 #4
0
        protected virtual IActionResult Response(object result)
        {
            if (OperacaoValida())
            {
                return(Ok(new
                {
                    success = true,
                    data = result
                }));
            }

            return(BadRequest(new
            {
                success = false,
                errors = _notifications.GetNotifications().Select(n => n.Value)
            }));
        }
コード例 #5
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var notificacoes = await Task.FromResult(_notifications.GetNotifications());

            notificacoes.ForEach(c => ViewData.ModelState.AddModelError(string.Empty, c.Value));

            return(View());
        }
コード例 #6
0
        private object GetResponse(object data = null)
        {
            if (_notificationHandler.HasNotifications())
            {
                return(_notificationHandler.GetNotifications());
            }

            return(data);
        }
コード例 #7
0
        protected async Task <IActionResult> ResponseAsync(object result = null)
        {
            if (await IsValidAsync())
            {
                return(Ok(new
                {
                    success = true,
                    data = result
                }));
            }

            return(BadRequest(new
            {
                success = false,
                errors = _notifications.GetNotifications().Select(n => n.Value)
            }));
        }
コード例 #8
0
        protected new ActionResult Response(object result = null)
        {
            if (IsValidOperation())
            {
                return(Ok(new
                {
                    success = true,
                    data = result
                }));
            }

            return(BadRequest(new
            {
                success = false,
                errors = _notification.GetNotifications().Select(n => n.Message)
            }));
        }
コード例 #9
0
        /// <summary>
        /// This method determines the response to the request processed by the business layer of the domain.
        /// </summary>
        /// <param name="commandResult">Result of the action returned by the business layer.</param>
        /// <returns>Response to request.</returns>
        protected CommandResponse FormatResponse(CommandResult commandResult)
        {
            CommandResponse commandResponse = new CommandResponse()
            {
                Success     = commandResult.Success,
                Message     = commandResult.Message,
                StatusCode  = commandResult.StatusCode,
                ElapsedTime = commandResult.ElapsedTime,
                Data        = commandResult.Data,
            };

            if (!commandResult.Success || _notificationHandler.HasNotification())
            {
                commandResponse.Errors = _notificationHandler.GetNotifications().Select(e => e.Notification).ToList();
            }

            return(commandResponse);
        }
コード例 #10
0
        public void Should_Get_Notifications()
        {
            _notification.RaiseError("Test");

            Assert.True(_notification.GetNotifications().Count == 1);
        }
コード例 #11
0
 public List <Notification> GetNotifications()
 {
     return(_notificationHandler.GetNotifications());
 }
コード例 #12
0
 protected IEnumerable <string> GetNotifications()
 {
     return(_notificationHandler.GetNotifications().Select(x => x.Value));
 }