/// <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); } }
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); }
protected IActionResult ResponseInvalid() { return(BadRequest(new { Messages = _notifications.GetNotifications().Select(x => x.Value) })); }
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) })); }
public async Task <IViewComponentResult> InvokeAsync() { var notificacoes = await Task.FromResult(_notifications.GetNotifications()); notificacoes.ForEach(c => ViewData.ModelState.AddModelError(string.Empty, c.Value)); return(View()); }
private object GetResponse(object data = null) { if (_notificationHandler.HasNotifications()) { return(_notificationHandler.GetNotifications()); } return(data); }
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) })); }
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) })); }
/// <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); }
public void Should_Get_Notifications() { _notification.RaiseError("Test"); Assert.True(_notification.GetNotifications().Count == 1); }
public List <Notification> GetNotifications() { return(_notificationHandler.GetNotifications()); }
protected IEnumerable <string> GetNotifications() { return(_notificationHandler.GetNotifications().Select(x => x.Value)); }