public async Task <IActionResult> StatementEdit(int id, StatementViewModel se) //public async Task<IActionResult> Edit(int id, [Bind("Id,Name")] T item) // тут толко указанные поля заполнит, остальные пустые (нулевые) { var item = se.Statement; if (id != item.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeExists(item.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(item)); }
public void GivenSortByDateSortByBucketShouldBeFalse() { StatementViewModel subject = Arrange(); subject.SortByDate = true; Assert.IsFalse(subject.SortByBucket); }
private static Transaction GetPhoneTxnFromGroupedList(StatementViewModel subject) { Transaction transactionFromGroupedList = subject.GroupedByBucket.Single(g => g.Bucket == StatementModelTestData.PhoneBucket) .Transactions.Single(t => t.Date == new DateTime(2013, 07, 16)); return(transactionFromGroupedList); }
private StatementViewModel Arrange() { StatementViewModel subject = CreateSubject().Initialise(this.mockTransactionService.Object); subject.Statement = StatementModelTestData.TestData1(); return(subject); }
public async Task <IActionResult> Statement(int id, int?page) { var vm = new StatementViewModel(); vm.Account = await _context.GetAccount(CustomerId, id); if (vm.Account == null) { ModelState.AddModelError("NoAccount", "Account not found"); return(View()); } var allTransactions = _context.GetAllAccountTransactions(id) .OrderByDescending(t => t.TransactionId) .ToList(); var paginated = new Paginator <Transaction>(allTransactions, page ?? 1); //go to first page if there was an error if (paginated.partialList == null) { return(RedirectToAction(nameof(Statement), new { id = id, page = 1 })); } vm.Transactions = paginated.partialList; vm.CurrentPage = paginated.currentPage; vm.NextPage = paginated.nextPage; vm.PrevPage = paginated.prevPage; return(View(vm)); }
private static Transaction GetPhoneTxnFromFullList(StatementViewModel subject) { Transaction transactionFromFullList = subject.Statement.Transactions .Single(t => t.BudgetBucket == StatementModelTestData.PhoneBucket && t.Date == new DateTime(2013, 07, 16)); return(transactionFromFullList); }
public void SetStatement_ShouldThrow_GivenInitialiseHasNotBeenCalled() { StatementViewModel subject = CreateSubject(); subject.Statement = StatementModelTestData.TestData1(); Assert.Fail(); }
public async Task <IActionResult> Index() { var userName = HttpContext.User.Claims.FirstOrDefault(user => user.Type.EndsWith("name"))?.Value; if (userName == null) { return(NotFound()); } var user = await _userManager.FindByNameAsync(userName); if (user == null) { return(NotFound()); } var allStatements = _context.AspUserStatement.Where(x => x.Id == user.Id).Join(_context.AspStatement, userStatement => userStatement.StatementId, statement => statement.StatementId, (userStatement, statement) => statement).ToList(); var statementViewModel = new StatementViewModel() { Statements = allStatements }; var statements = _statementService.GetAllStatements(); return(View(statementViewModel)); }
public bool CreateStatement(StatementViewModel statement) { var conn = _db.OpenConnection(); try { var command = conn.CreateCommand(); var cmdSql = @"INSERT INTO sagradacruz.statement (author, creation_date, city, content, state) VALUES (@author, current_date(), @city, @content, 'W')"; command.CommandText = cmdSql; _db.ClearParameters(ref command); _db.AddInParameter(ref command, "@author", statement.Author); _db.AddInParameter(ref command, "@city", statement.City); _db.AddInParameter(ref command, "@content", statement.Content); var result = command.ExecuteNonQuery(); return(result > 0); } catch (Exception) { return(false); } finally { conn.Close(); conn.Dispose(); } }
public void GivenTestData2OutputGroupedList() { StatementViewModel subject = Arrange(); subject.SortByBucket = true; subject.UpdateGroupedByBucket(); foreach (TransactionGroupedByBucketViewModel group in subject.GroupedByBucket) { Console.WriteLine( "{0}, AvgDr:{1:C} {2:d} {3:d} Count:{4} TotalCr:{5:C} TotalDr{6:C} Diff{7:C}", group.Bucket, group.AverageDebit, group.MinTransactionDate, group.MaxTransactionDate, group.TotalCount, group.TotalCredits, group.TotalDebits, group.TotalDifference); foreach (Transaction transaction in group.Transactions) { Console.WriteLine( " {0:d} {1:C} {2}", transaction.Date, transaction.Amount, transaction.Description); } } }
public void GivenSortByDateUpdateGroupedByBucketShouldNotUpdateGroupedList() { StatementViewModel subject = Arrange(); subject.SortByBucket = true; subject.SortByDate = true; subject.UpdateGroupedByBucket(); Assert.IsFalse(subject.GroupedByBucket.Any()); }
public void TriggerRefreshTotalsRowShouldRaise10Events() { StatementViewModel subject = Arrange(); var eventCount = 0; subject.PropertyChanged += (s, e) => eventCount++; subject.TriggerRefreshTotalsRow(); Assert.AreEqual(8, eventCount); }
// GET: Statement public ActionResult Index(DateTime?from, DateTime?to) { StatementViewModel statementViewModel = statementRepository.getPricesTotal(from, to); statementViewModel.prices = statementRepository.getPricesConsolidated(from, to); statementViewModel.from = from == null ? null : from; statementViewModel.to = to == null ? null : to; return(View(statementViewModel)); }
public StatementViewModel GetAllStatements() { var statements = _context.AspStatement.ToList(); var statementViewModel = new StatementViewModel() { Statements = statements }; return(statementViewModel); }
public StatementViewModel getPricesTotal(DateTime?from, DateTime?to) { StatementViewModel total = new StatementViewModel(); string conn = ConfigurationManager.ConnectionStrings["MysqlConnection"].ConnectionString; MySqlConnection mySqlConnection = new MySqlConnection(conn); //string sqlquery = @"SELECT COUNT(p.fk_Security) as 'Sold count', // SUM(p.value) as 'Sold sum to nominal_value' // FROM prices p // INNER JOIN securities s ON p.fk_Security = s.ticker // INNER JOIN companies c ON c.code = s.fk_Company // WHERE p.from_date >= IFNULL(?from, p.from_date) AND // p.to_date <= IFNULL(?to, p.to_date)"; string sqlquery = @" SELECT COUNT(p.fk_Security) as 'Sold count', (SUM(p.value) * COUNT(p.fk_Security) - my2.suma) as 'Sold sum to nominal_value' FROM ( SELECT SUM(my.xx) as suma FROM ( SELECT COUNT(p.fk_Security) * SUM(p.value) as xx FROM prices p INNER JOIN securities s ON p.fk_Security = s.ticker INNER JOIN companies c ON c.code = s.fk_Company WHERE p.from_date >= IFNULL(?from, p.from_date) AND p.to_date <= IFNULL(?to, p.to_date) GROUP BY p.fk_Security ) my ) my2, prices p INNER JOIN securities s ON p.fk_Security = s.ticker INNER JOIN companies c ON c.code = s.fk_Company WHERE p.from_date >= IFNULL(?from, p.from_date) AND p.to_date <= IFNULL(?to, p.to_date) "; MySqlCommand mySqlCommand = new MySqlCommand(sqlquery, mySqlConnection); mySqlCommand.Parameters.Add("?from", MySqlDbType.DateTime).Value = from; mySqlCommand.Parameters.Add("?to", MySqlDbType.DateTime).Value = to; mySqlConnection.Open(); MySqlDataAdapter mda = new MySqlDataAdapter(mySqlCommand); DataTable dt = new DataTable(); mda.Fill(dt); mySqlConnection.Close(); foreach (DataRow item in dt.Rows) { total.amount = Convert.ToInt32(item["Sold count"] == System.DBNull.Value ? 0 : item["Sold count"]); total.sum = Convert.ToDecimal(item["Sold sum to nominal_value"] == System.DBNull.Value ? 0 : item["Sold sum to nominal_value"]); } return(total); }
public async Task <IActionResult> UploadStatement(StatementViewModel statement) { try { var upload = await _context.SaveFileUploadAsync(statement.Attachment); } catch (Exception ex) { throw new Exception("Failed to save uploaded file. Please upload it again later.", ex); } return(View("UploadStatementResult", statement)); }
public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var tcontext = _context.Set <T>(); var entity = await tcontext.FindAsync(id); if (entity == null) { return(NotFound()); } if (entity is Statement sst) // для ведомости вид StatementEdit и модель StatementViewModel { var stEdit = new StatementViewModel() { Statement = sst }; var setMmarks = _context.Set <Mark>().Where(m => m.StatementId == sst.Id).ToList(); // имеющиеся отметки // срисок отметок для всех студентов группы var allMarks = _context.Set <Student>().Where(s => s.GroupId == sst.GroupId).Select(s => new Mark() { Id = 0, StatementId = sst.Id, StudentId = s.Id }).ToList(); var unMarks = setMmarks.Union(allMarks, new MarkComparer()).ToList(); foreach (var m in unMarks) { if (m.Id == 0) { m.Student = _context.Set <Student>().Find(m.StudentId); } } stEdit.Marks = unMarks.OrderBy(m => m.Student.Name).ToList(); return(View("StatementEdit", stEdit)); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } else if (entity is Mark mrk) { return(View("EditMark", entity)); } else { return(View(entity)); } }
public Statement(StatementViewModel statement) { this.StatementID = statement.StatementID; this.PaymentID = statement.PaymentID; this.BudgetID = statement.BudgetID; this.Description = statement.Description; this.WithdrawAmount = statement.WithdrawAmount; this.PreviousAmount = statement.PreviousAmount; this.RemainAmount = statement.RemainAmount; RecordStatus rs; Enum.TryParse(statement.Status, out rs); this.Status = rs; }
private void DoShowStatementCmd() { StatementView StatementView = new StatementView(); StatementViewModel StatementVM = new StatementViewModel(_UnitOfWork, StatementView, _MonthList, _selectedMonthId); StatementView.DataContext = StatementVM; StatementView.ShowDialog(); if (StatementView.DialogResult.HasValue && StatementView.DialogResult.Value) { RefreshList(_selectedMonthId); } }
public async Task <IActionResult> GetHistory(DateTime from, DateTime to) { if (!caller.Identity.IsAuthenticated) { return(BadRequest("User not authenticated")); } // retrieve the user info var userId = int.Parse(caller.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value); var accountNumber = int.Parse(caller.Claims.SingleOrDefault(c => c.Type == "account_number").Value); var statement = new StatementViewModel { UserId = userId, AccountNumber = accountNumber, FromDate = from, ToDate = to }; var result = await accountAppServices.GetStatements(statement, CancellationToken.None); return(ValidationHandler(statement, result)); }
public ActionResult Statement(long id, int?year) { if (!year.HasValue) { year = DateTime.Now.Year; } var parent = repository.GetUser(id); var canview = parent.GetCanView(sessionid.Value, auth); if (!canview) { return(ReturnNoPermissionView()); } var viewmodel = new StatementViewModel(parent, year.Value, auth.perms); return(View(viewmodel)); }
public IActionResult New(StatementViewModel statement) { var strSession = Utils.ConvertBytesToString(HttpContext.Session.Get("SESSION")); if (string.IsNullOrEmpty(strSession)) { return(RedirectToAction("Index", "Home")); } var session = JsonConvert.DeserializeObject <ActiveSession>(strSession); if (session.Status) { var result = dAO.CreateStatement(statement); return(Json(result)); } else { return(RedirectToAction("Index", "Home")); } }
public IActionResult Get(DateTime?from) { Account account; if (from.HasValue) { account = _repos.Accounts.GetAccountWithCustomerAndTransactionsFromDate(_accountId, from.Value); } else { account = _repos.Accounts.GetAccountWithCustomerAndTransactions(_accountId); } var statement = new StatementViewModel() { AccountId = account.AccountId, CustomerName = account.Customer.Name, Balance = account.Balance }; foreach (var transaction in account.Transactions) { statement.Transactions.Add(new TransactionViewModel() { TransactionId = transaction.TransactionId, Date = transaction.Date, Description = transaction.Description, Credit = transaction.Amount > 0 ? transaction.Amount as decimal? : null, Debit = transaction.Amount < 0 ? transaction.Amount as decimal? : null, Type = transaction.Type, Status = transaction.Status }); } _logger.LogInformation($"Someone asked for a statement"); return(Ok(statement)); }
public IActionResult MemberStatements(int productPage = 1) { StatementViewModel statementVM = new StatementViewModel() { Statements = _context.Statements.Where(a => a.ApplicationUserId == _userManager.GetUserId(User)).OrderByDescending(a => a.Id), }; var count = statementVM.Statements.Count(); statementVM.Statements = statementVM.Statements.OrderByDescending(p => p.Id) .Skip((productPage - 1) * PagSize) .Take(PagSize).ToList(); statementVM.PagingInfo = new PagingInfo { CurrentPage = productPage, ItemsPerPage = PagSize, TotalItem = count }; return(View(statementVM)); }
public ActionResult Statement(int accountId, int year, int month) { var account = accountRepository.Find(accountId); var date = DateService.GetMonthYearDate(year, month); var transactions = transactionRepository.All.Where(x => x.AccountId == accountId && x.Date.Year == year && x.Date.Month == month).ToList(); var transfersOut = transferRepository.All.Where(x => x.AccountId == accountId && x.Date.Year == year && x.Date.Month == month).ToList(); var transfersIn = transferRepository.All.Where(x => x.ToAccountId == accountId && x.Date.Year == year && x.Date.Month == month).ToList(); foreach (var transfer in transfersOut) { transfer.Amount = -transfer.Amount; } var activities = new List <IAccountActivity>(); activities.AddRange(transactions); activities.AddRange(transfersOut); activities.AddRange(transfersIn); var accountActivitiesVM = activities.OrderByDescending(x => x.Date).Select(x => new AccountActivitiesViewModel(x)).ToList(); var viewModel = new StatementViewModel { AccountId = accountId, AccountName = account.Name, StatementDate = date, PreviousMonth = DateService.PreviousMonth(year, month), PreviousYear = DateService.PreviousYear(year, month), NextMonth = DateService.NextMonth(year, month), NextYear = DateService.NextYear(year, month), Activities = accountActivitiesVM, MoneyIn = activities.Sum(x => x.Amount > 0 ? x.Amount : 0), MoneyOut = activities.Sum(x => x.Amount < 0 ? x.Amount : 0) }; return(View(viewModel)); }
public async Task <Result> GetStatements(StatementViewModel statement, CancellationToken cancellationToken = default) { var request = mapper.Map <Commands.Statement.Request>(statement); return(await mediator.SendCommand(request, cancellationToken)); }
public AddStatementCommand(StatementViewModel viewModel, SemanticNetworkNode semanticNetworkNode, IInventorApplication application) : base(semanticNetworkNode, application) { ViewModel = viewModel; }
public EditStatementCommand(StatementViewModel viewModel, StatementViewModel previousVersion, SemanticNetworkNode semanticNetworkNode, IInventorApplication application) : base(semanticNetworkNode, application) { ViewModel = viewModel; PreviousVersion = previousVersion; }
public void GivenTestData1StatementNameShouldBeFooStatement() { StatementViewModel subject = Arrange(); Assert.AreEqual("FooStatement", subject.StatementName); }
public void GivenTestData1TotalCreditsShouldBe0() { StatementViewModel subject = Arrange(); Assert.AreEqual(0, subject.TotalCredits); }