public IQueryable <Transaction> GetTransactionsInEur([FromRoute] string sku) { IQueryable <Transaction> trs = transactionRep.GetAllByField("Sku", sku); IQueryable <Rate> rts = rateRep.GetAll(); return(TransactionConverter.CalculateAlgorithm(rts, trs, "EUR")); }
public bool TryGetMonthReports(FileData data, out TransactionReport report) { report = new TransactionReport(); string header = data.Lines.First(); bool canParse = CheckIfCanParse(header); if (!canParse) { return(false); } int startIndex = GetStartIndex(data); int count = data.Lines.Count - startIndex - 4; List <string> transactionLines = data.Lines.Skip(startIndex + 1).Take(count).ToList(); List <TransactionING> ingTransactions = new List <TransactionING>(); foreach (string line in transactionLines) { var transaction = GetFromLine(line); ingTransactions.Add(transaction); } TransactionConverter converter = new TransactionConverter(); report.Transactions = converter.GetFromIngTransaction(ingTransactions); return(true); }
public IQueryable <Transaction> GetSvcTransactionsInEur([FromRoute] string sku) { IQueryable <Transaction> trs = transactionsvc.GetTransactionsBySku(sku); IQueryable <Rate> rts = ratesvc.GetAllRates(); return(TransactionConverter.CalculateAlgorithm(rts, trs, "EUR")); }
public TransactionRepository(IMyWalletDatabaseSettings settings) { var client = new MongoClient(settings.ConnectionString); _database = client.GetDatabase(settings.DatabaseName); _collection = _database.GetCollection <TransactionDTO>("Transactions"); _transactionConverter = new TransactionConverter(); }
public async Task CreateAsync(Transaction entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } var transaction = TransactionConverter.Convert(entity); await _session.InsertAsync(transaction); }
public ServiceResponse <bool> Create([FromBody] CreateTransactionModel createModel) { var response = new ServiceResponse <bool>(); var creditCardModel = _creditCardService.GetByToken(createModel.Token); if (creditCardModel.IsSuccessed) { TransactionModel model = new TransactionConverter().ConvertCreateModel(createModel); decimal amount; decimal.TryParse(createModel.Amount, out amount); if (_braintreeWarpper.Sale(amount, createModel.Token)) { model.IsActive = true; model.IsDeleted = false; model.CreditCardId = creditCardModel.Data.ID; var validationResult = _transactionModelValidator.Validate(model); if (validationResult.IsValid) { var entity = new TransactionConverter().Convert(model); var serviceResponse = _transactionService.Create(entity); response.IsSuccessed = serviceResponse.IsSuccessed; response.Errors = serviceResponse.Errors; response.Data = true; } else { _logger.Error("{source} {template} {logtype} {ValidationError}", "controller", "TransactionEntity", "validationerror", validationResult.Errors); response.IsSuccessed = false; response.Errors = new ValidationFailureConverter().Convert(validationResult.Errors.ToList()); } } else { response.IsSuccessed = false; response.Errors.Add(new ServiceError() { InnerMessage = "Payment Error.", Message = "There is an error with payment! Please contact.", Code = "2009062057" }); } } else { response.IsSuccessed = false; response.Errors.Add(new ServiceError() { InnerMessage = "Token not found in the credit card table.", Message = "There is an error with payment! Please contact.", Code = "2009062304" }); } return(response); }
public ServiceResponse <List <TransactionModel> > List() { var response = new ServiceResponse <List <TransactionModel> >(); var transactionConverter = new TransactionConverter(); var serviceResponse = _transactionService.ListForUser(CurrentUser.ID); if (serviceResponse.IsSuccessed) { response.Data = transactionConverter.Convert(serviceResponse.Data); } response.IsSuccessed = serviceResponse.IsSuccessed; return(response); }
public void ConvertTest() { var converter = new TransactionConverter(); string[] values = { "1000", "Title", "Category" }; var transation = converter.Convert(values, typeof(Transaction), null, System.Globalization.CultureInfo.CurrentCulture) as Transaction; Assert.AreEqual(transation.Value.ToString(), values[0]); Assert.AreEqual(transation.Title, values[1]); Assert.AreEqual(transation.Category, values[2]); }
public async Task <Transaction> GetAsync(Guid id) { var transaction = await _session.Query <Models.Transaction>() .Where(t => t.Id == id.ToString()) .Select(t => new Models.Transaction { Id = t.Id, Date = t.Date, Amount = t.Amount, Category = t.Category }) .FirstOrDefaultAsync(); if (transaction == null) { return(null); } return(TransactionConverter.Convert(transaction)); }
public DataView() { InitializeComponent(); DataContext = this; var app = Application.Current as App; _loanController = app.LoanController; _transactionController = app.TransactionController; Data = new ObservableCollection <UserControl>(TransactionConverter .ConvertTransactionListToTransactionViewList(_transactionController .GetAll() .ToList())); LoanConverter .ConvertLoanListToLoanViewList(_loanController .GetAll() .ToList()) .ToList() .ForEach(Data.Add); }
private void SaveChanges() { DateTime date = DateTimeHelper.PstNow(); int changeSuccessCount = 0; foreach (Transaction transaction in Transactions) { if (transaction.HasUpdated) { CarloniusRepository.UpdateTransaction(TransactionConverter.ConvertToBudget_Transaction(transaction)); CarloniusRepository.AddDateTimeLookup(transaction.DateTime); transaction.HasUpdated = false; ChangesMade = false; date = transaction.DateTime; changeSuccessCount++; } } MessageBox.Show(string.Format("{0} Change(s) Saved Successfully!", changeSuccessCount), "Transaction Update", MessageBoxButton.OK, MessageBoxImage.None); if (DateTimeHelper.AreEqual(date, Date)) { UpdateTransactions(Date); } }
public void UpdateTransactions(IEnumerable <DateTime> dates) { Transactions = TransactionConverter.ConvertToTransactions(CarloniusRepository.GetTransactionsByDateTimes(dates)); AmountTotal = CalculateTotal(); }
public TransactionService(ITransactionRepository <ITransaction> transactionRepository) { _transactionRepository = transactionRepository; _transactionConverter = new TransactionConverter(); }
public void UpdateTransactions(DateTime date) { Transactions = TransactionConverter.ConvertToTransactions(CarloniusRepository.GetTransactionsByDateTime(date)); }
private void DeleteTransaction() { CarloniusRepository.DeleteTransaction(TransactionConverter.ConvertToBudget_Transaction(SelectedTransaction)); Transactions.Remove(SelectedTransaction); }
private void UpdateDataView(Transaction transaction) => _dataView.Data.Add(TransactionConverter.ConvertTransactionToTransactionView(transaction));
private List <JSON.API.Internals.Transaction> GetTransactions(SessionSubscriptor subscriptor, SignedLedger ledger) { return(ledger.Ledger.Block.Transactions .Where(transaction => subscriptor.IsSubscribed(transaction, true)) .Select(signed => TransactionConverter.GetTransaction(signed.Transaction)).ToList()); }
private void DispatchRequest(ISession session, Request request, Action <Response, ResultCode> sendResponse) { if (request is SendTransactionRequest) { var message = (SendTransactionRequest)request; if (!RequestHelper.TryReadSignedTransaction(message, out var signed)) { sendResponse.Call(ResponseHelper.CreateSendTransactionResponse(), ResultCode.CannotReadSignedTransaction); return; } LiveService.AddCommand(new SendTransactionCommand(signed, (r, rc) => { if (rc == ResultCode.Success) { ExplorerConnectionService.SubscriptionManager.ListenTo(session, new TransactionTopic(signed.Hash)); } sendResponse.Call(ResponseHelper.CreateSendTransactionResponse(signed.Hash), rc); })); } else if (request is GetSignedLedgerRequest) { var message = (GetSignedLedgerRequest)request; if (!message.Height.HasValue) // Get current ledger { var ledger = LedgerService.LedgerManager.GetSignedLedger(); sendResponse.Call(ResponseHelper.CreateGetSignedLedgerResponse(ledger), ResultCode.Success); return; } var height = message.Height.Value; if (height < 0) { sendResponse.Call(ResponseHelper.CreateGetSignedLedgerResponse(), ResultCode.InvalidInputParam); return; } var currentHeight = LedgerService.LedgerManager.GetSignedLedger().GetHeight(); if (height > currentHeight) { sendResponse.Call(ResponseHelper.CreateGetSignedLedgerResponse(), ResultCode.LedgerDoesnotExist); return; } if (height == currentHeight) { var ledger = LedgerService.LedgerManager.GetSignedLedger(); sendResponse.Call(ResponseHelper.CreateGetSignedLedgerResponse(ledger), ResultCode.Success); return; } var signed = DatabaseService.ReadDatabaseManager.GetLedgerFromRaw(height); if (signed == null) { sendResponse.Call(ResponseHelper.CreateGetSignedLedgerResponse(), ResultCode.LedgerDoesnotExist); return; } sendResponse.Call(ResponseHelper.CreateGetSignedLedgerResponse(signed), ResultCode.Success); } else if (request is GetBalanceRequest) { var message = (GetBalanceRequest)request; var command = new GetAccountCommand(message.Address, (acc, rc) => sendResponse(ResponseHelper.CreateGetBalanceResponse(acc), rc)); LiveService.AddCommand(command); } else if (request is GetAccountRequest) { var message = (GetAccountRequest)request; var command = new GetAccountCommand(message.Address, (acc, rc) => sendResponse(ResponseHelper.CreateGetAccountResponse(acc), rc)); LiveService.AddCommand(command); } else if (request is GetTransactionRequest) { var message = (GetTransactionRequest)request; byte[] hash; try { hash = Convert.FromBase64String(message.Hash); } catch (Exception) { sendResponse.Call(ResponseHelper.CreateGetTransactionResponse(), ResultCode.NotABase64); return; } if (hash.Length != TransactionHash.SIZE) { sendResponse.Call(ResponseHelper.CreateGetTransactionResponse(), ResultCode.NotAHash256); return; } var transaction = ExplorerDatabaseService.ReadDatabaseManager.GetTransaction(new TransactionHash(hash)); sendResponse.Call(ResponseHelper.CreateGetTransactionResponse(TransactionConverter.GetTransaction(transaction)), ResultCode.Success); } else if (request is GetTransactionHistoryRequest) { var message = (GetTransactionHistoryRequest)request; Address address; try { address = new Address(message.Address); } catch (Exception) { sendResponse.Call(ResponseHelper.CreateGetTransactionHistoryResponse(), ResultCode.ReadAddressFailure); return; } if (message.Count <= 0) { sendResponse.Call(ResponseHelper.CreateGetTransactionHistoryResponse(), ResultCode.InvalidInputParam); return; } if (message.Page <= 0) { sendResponse.Call(ResponseHelper.CreateGetTransactionHistoryResponse(), ResultCode.InvalidInputParam); return; } // TODO this is a temporary hack { var raw = ExplorerDatabaseService.ReadDatabaseManager.GetTransactionHistory(address, message.Height).OrderByDescending(_ => _.LedgerHeight).ToList(); var total = raw.Count; raw = raw.Skip(message.Count * (message.Page - 1)).Take(message.Count).ToList(); var results = new List <HistoricalTransaction>(); foreach (var transaction in raw) { var ledger = DatabaseService.ReadDatabaseManager.GetLedgerFromRaw(transaction.LedgerHeight); results.Add(new HistoricalTransaction(transaction.LedgerHeight, transaction.Transaction, ledger.GetTimestamp())); } var transactions = results.Select(TransactionConverter.GetHistoricalTransaction).ToList(); sendResponse.Call(ResponseHelper.CreateGetTransactionHistoryResponse(transactions, total), ResultCode.Success); } } else if (request is GetLedgerRequest) { var message = (GetLedgerRequest)request; if (message.Height != null && message.Height >= 0) { var currentHeight = LedgerService.LedgerManager.GetSignedLedger().GetHeight(); if (message.Height > currentHeight) { sendResponse.Call(ResponseHelper.CreateGetLedgerResponse(), ResultCode.LedgerDoesnotExist); return; } if (message.Height == currentHeight) { sendResponse.Call(ResponseHelper.CreateGetLedgerResponse(LedgerConverter.GetLedger(LedgerService.LedgerManager.GetSignedLedger())), ResultCode.Success); return; } var signed = DatabaseService.ReadDatabaseManager.GetLedgerFromRaw(message.Height.Value); if (signed == null) { sendResponse.Call(ResponseHelper.CreateGetLedgerResponse(), ResultCode.LedgerDoesnotExist); return; } var ledger = LedgerConverter.GetLedger(signed); sendResponse.Call(ResponseHelper.CreateGetLedgerResponse(ledger), ResultCode.Success); return; } if (!string.IsNullOrEmpty(message.Hash)) { try { var bytes = Convert.FromBase64String(message.Hash); var ledger = DatabaseService.ReadDatabaseManager.GetLedgerByHash(new LedgerHash(bytes)); sendResponse.Call(ResponseHelper.CreateGetLedgerResponse(LedgerConverter.GetLedger(ledger)), ResultCode.Success); return; } catch (Exception e) { sendResponse.Call(ResponseHelper.CreateGetLedgerResponse(), ResultCode.InvalidInputParam); return; } } sendResponse.Call(ResponseHelper.CreateGetLedgerResponse(), ResultCode.InvalidInputParam); } else if (request is GetOrderBookRequest) { var message = (GetOrderBookRequest)request; if (message.Symbol.IsNullOrEmpty() || !OrderBookService.GetSymbols().Contains(message.Symbol)) { sendResponse.Call(ResponseHelper.CreateGetOrderBookResponse(null, message.Symbol), ResultCode.InvalidInputParam); return; } OrderBookService.GetOrderBook(message.Symbol, (ob) => sendResponse(ResponseHelper.CreateGetOrderBookResponse(OrderConverter.GetOrders(ob), message.Symbol), ResultCode.Success)); } else if (request is SubscribeRequest) { var message = (SubscribeRequest)request; if (TopicsConverter.TryGetTopic(message.Topic, OrderBookService.GetSymbols(), out var topic)) { ExplorerConnectionService.SubscriptionManager.ListenTo(session, topic); sendResponse(ResponseHelper.CreateSubscribeResponse(), ResultCode.Success); return; } sendResponse(ResponseHelper.CreateSubscribeResponse(), ResultCode.InvalidInputParam); } else if (request is GetLatestLedgersRequest) { var height = LedgerService.LedgerManager.GetSignedLedger().GetHeight(); var ledgers = DatabaseService.ReadDatabaseManager.GetLedgersFromHeight(height - 9); var results = ledgers.Select(LedgerConverter.GetLedger).ToList(); sendResponse.Call(ResponseHelper.CreateGetLatestLedgersResponse(results), ResultCode.Success); } else { sendResponse.Call(new Response(), ResultCode.UnknownMessage); } }