private async Task <IEnumerable <TransactionViewModel> > GetTransactions() { var transactions = _transactionServices.GetTransactions(); if (transactions != null && transactions.Any()) { transactions = transactions.OrderBy(t => t.OperationDate); return(await GetTransactionsViewModel(transactions)); } return(new List <TransactionViewModel>()); }
public void ShouldHaveListOfTransactionWhenIGetTransactions() { // Arrange var faker = new Faker(); var csvPath = faker.Random.String2(2); _transactionServices.LoadTransactions(csvPath); // Act var transactions = _transactionServices.GetTransactions(); // Assert Assert.True(transactions.Any()); }
public async Task <ActionResult> Compare(List <CsvFileViewModel> csvFiles) { var compareTransactionList = new CompareViewModel(); var selectedCsvFiles = csvFiles.Where(c => c.IsChecked).ToList(); if (selectedCsvFiles == null) { ViewBag.Error = _localizer["EmptySelectedCsvFileError"]; return(View(compareTransactionList)); } if (selectedCsvFiles.Count < 2 || selectedCsvFiles.Count > 4) { ViewBag.Error = _localizer["BadNumberOfCsv"]; return(View(compareTransactionList)); } var transactionsToCompare = new List <TransactionsViewModel>(); foreach (var selectedFile in selectedCsvFiles) { var filePath = GetFullFilePath(selectedFile.FileName); try { var transactions = _transactionServices.GetTransactions(filePath); var groupedTransactions = _transactionServices.GetGroupedTransactionsByCategory(transactions); if (groupedTransactions == null || !groupedTransactions.Any()) { ViewBag.Error = _localizer["EmptyTransactionList"]; return(View(compareTransactionList)); } var transactionViewModels = GetTransactionViewModels(groupedTransactions); transactionViewModels = await AppendMissingCategoryTransactions(transactionViewModels); var transactionsViewModelOrdered = transactionViewModels.OrderBy(t => t.Category.Name.ToString()).AsEnumerable(); transactionsViewModelOrdered = UnsignAmount(transactionsViewModelOrdered); var transactionsViewModel = GetTransactionsViewModel(transactionsViewModelOrdered); transactionsToCompare.Add(transactionsViewModel); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View(compareTransactionList)); } } compareTransactionList.TransactionsToCompare = OrderedTransactionsByDate(transactionsToCompare); CompareToAdjustTransactionColor(compareTransactionList); return(View(compareTransactionList)); }
public async Task <ActionResult> GetTransactions(long userId, [FromQuery] UserTransactionsParams transactionsParams) { if (!_customAuth.IsUserAllowedAccess(userId, HttpContext)) { return(StatusCode(401)); } var response = await _tranService.GetTransactions(userId, transactionsParams); return(StatusCode(response.Status, response)); }
//Manage Transaction// // GET: /Admin/ManageTransaction public IActionResult ManageTransaction(int?page) { if (IsAdmin()) { int maxSize = 9; var pageNum = page ?? 1; var transactions = _transactionServices.GetTransactions().OrderByDescending(x => x.TimeSend).ToPagedList(pageNum, maxSize); ViewBag.page = transactions; return(View()); } Alert("You not permit to access this page", NotificationType.error); return(RedirectToAction("Login", "Home")); }