public async Task <bool> ColumnSync() { try { var syscat = await _syscatRepository.GetColumn().ConfigureAwait(false); var columns = await _columnRepository.GetAll().ConfigureAwait(false); if (syscat is null || columns is null) { return(false); } columns = columns.Where(x => x.SyncId != null); var inserts = syscat.AsParallel().Where(x => x.IsInsert(columns)).Select(x => x.GetEntityInsert); var updates = syscat.AsParallel().Where(x => x.IsUpdate(columns)).Select(x => x.GetEntityUpdate); return((await Task.WhenAll( new Task <bool>[] { _columnRepository.Insert(inserts) , _columnRepository.Update(updates) }).ConfigureAwait(false)).All(x => x)); } catch (ExternalException e) { _notification.AddNotification(e.StackTrace, e.Message, LogLevel.Error); return(false); } }
public IActionResult Index(string tableName, string name = Consts.NullString) { if (string.IsNullOrWhiteSpace(tableName)) { return(RedirectToAction(nameof(Index), "Table")); } IEnumerable <ColumnEntity> result = null; try { result = _columnRepository.GetAll(tableName, name).Result; } catch (ExternalException e) { _notification.AddNotification(e.StackTrace, e.Message, LogLevel.Error); } if (result != null) { return(View(result.Select(x => x.GetViewModel))); } else { return(RedirectToAction(nameof(Index), "Table")); } }
public DB2Repository(IOptions <DB2Setting> db2Settings, INotification notification) { if (notification != null) { _notification = notification; } if (db2Settings?.Value?.GetBuilder != null) { _cnn = db2Settings.Value.GetBuilder.ConnectionString; } else if (_notification != null) { _notification.AddNotification(Resources.DB2SettingMissing, "ArgumentNull", LogLevel.Error); } }
public ActionResult Add(NotificationsTB NotificationsTB) { try { if (!ModelState.IsValid) { return(View(NotificationsTB)); } _INotification.DisableExistingNotifications(); var Notifications = new NotificationsTB { CreatedOn = DateTime.Now, Message = NotificationsTB.Message, NotificationsID = 0, Status = "A", FromDate = NotificationsTB.FromDate, ToDate = NotificationsTB.ToDate }; _INotification.AddNotification(Notifications); MyNotificationHub.Send(); return(RedirectToAction("Add", "AddNotification")); } catch (Exception) { throw; } }
/// <summary> /// On Exception Pipeline /// </summary> /// <param name="context">Exception Context</param> public void OnException(ExceptionContext context) { if (context is null) { return; } _notification.AddNotification(context.Exception.StackTrace, context.Exception.Message, LogLevel.Error); }
public async Task <T> ExecuteAsync <T>(Func <Task <T> > action) { try { return(await action()); } catch (NotFoundException e) { _notification.AddNotification("Not Found", e.Message, NotificationModel.ENotificationType.NotFound); return(default);
private async Task <AccountResponse> ExecutarTrasferencia(Guid trasnferenciaID, TransferenciaEntity transferenciaEntity) { _notification.ClearNotifications(); var accountResponse = new AccountResponse(); var account = await ValidarConta(transferenciaEntity.Conta); account.Validate(account); if (!account.Valid) { _notification.AddNotifications(account.ValidationResult); accountResponse.Success = false; } if (transferenciaEntity.TipoTransacao == Common.Enums.Transacao.ETipoTransacao.Debito) { if (account.Balance < transferenciaEntity.Valor) { _notification.AddNotification("Conta", "Conta sem saldo para transferencia"); accountResponse.Success = false; } } if (!_notification.HasNotifications) { var request = new AccountRequest() { AccountNumber = transferenciaEntity.Conta, Type = transferenciaEntity.TipoTransacao == Common.Enums.Transacao.ETipoTransacao.Debito ? Common.Enums.Transacao.AccountTransactionType.Debit : Common.Enums.Transacao.AccountTransactionType.Credit, Value = transferenciaEntity.Valor }; accountResponse = await _accountHttpClient.InserirTrasactionAccount(request); } transferenciaEntity.AtribuirIdTransferencia(trasnferenciaID); await InserirTransferencia(transferenciaEntity); return(accountResponse); }
public IHttpActionResult AddNotification(AddNotificationRequest addNotificationRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var notification = new Notification() { RegulationId = addNotificationRequest.RegulationId, MasterDirectionId = addNotificationRequest.MasterDirectionId, NotificationNumber = addNotificationRequest.NotificationNumber, NotificationName = addNotificationRequest.NotificationName, NotificationDate = addNotificationRequest.NotificationDate, NotificationEffectiveDate = addNotificationRequest.NotificationEffectiveDate, NotificationTypeId = addNotificationRequest.NotificationTypeId, GSRNo = addNotificationRequest.GSRNo, GSRDate = addNotificationRequest.GSRDate, NotificationPDF = addNotificationRequest.NotificationPDF, GSRPDF = addNotificationRequest.GSRPDF, CreatedBy = Utility.UserId }; int result = iNotification.AddNotification(notification); if (result > 0) { responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "Notification added successfully."; } else if (result == -2) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Notification alread exists."; } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding notification."; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding notification."; Utility.WriteLog("AddNotification", addNotificationRequest, "Error while adding notification. (NotificationAdminController)", ex.ToString()); } return(Ok(responses)); }
public async Task <TrasactionResponse> ConsultarTrasnferencia(string transactionId) { TrasactionResponse response = new TrasactionResponse(); if (string.IsNullOrEmpty(transactionId)) { _notification.AddNotification("Erro", "O campo transactionId é obrigatorio"); return(response); } var resutadoTransferencia = await _transferenciaService.ConsultarTrasnferencia(transactionId); if (resutadoTransferencia == null) { _notification.AddNotification("Erro", "Transferencia não encontrada."); return(response); } response.Data = _mapper.Map <TrasactionDto>(resutadoTransferencia); return(response); }
public CustomerDTO Execute(CustomerDTO customer) { var _customer = _mapper.Map <Customer>(customer); if (!_customer.IsValid) { _notification.AddNotification(_customer.Notifications); return(customer); } // var checkIfAlreadyExists = _customerRepository.GetById(customer.Hash); // if(checkIfAlreadyExists != null) // { // _notification.AddNotification("customer","already exist"); // return customer; // } _customerRepository.Create(_customer); return(_mapper.Map <CustomerDTO>(_customer)); }
public async Task <AccountResponse> InserirTrasactionAccount(AccountRequest accountRequest) { var response = new AccountResponse(); var resposta = await PostAsJsonAsync($"{"Account/"}", new JsonContent(accountRequest)); if (!resposta.IsSuccessStatusCode) { switch (resposta.StatusCode) { case HttpStatusCode.InternalServerError: _notification.AddNotification("Erro ", " Problema ao acessar API Conta"); break; default: _notification.AddNotification("Erro ", " Ocorreu um erro inesperado. Tente novamente mais tarde."); break; } response.Success = false; return(response); } return(response); }
public void SendNotification(string message, string user) { objRepository.AddNotification(message, user); }