示例#1
0
        public async Task UpdateAccount(Account account, CancellationToken token)
        {
            if (account == null)
            {
                return;
            }

            var existAccount = await _context.Accounts.FirstOrDefaultAsync(a => a.Id == account.Id, token);

            if (existAccount == null)
            {
                return;
            }

            existAccount.Balance        = account.Balance;
            existAccount.Currency       = account.Currency;
            existAccount.Title          = account.Title;
            existAccount.Type           = account.Type;
            existAccount.IsArchived     = account.IsArchived;
            existAccount.IsDeleted      = account.IsDeleted;
            existAccount.IsSynchronized = account.IsSynchronized;

            _context.Accounts.Update(existAccount);
            await _context.SaveChangesAsync(token);
        }
        public async Task Invoke_Default_ReturnedChart()
        {
            await _context.BudgetOperations.AddRangeAsync(Operations.GetBudgetOperations());

            await _context.SaveChangesAsync();

            var command = new GetChartCommand
            {
                From   = new DateTime(2020, 10, 1),
                To     = new DateTime(2020, 10, 30),
                UserId = Guid.Empty
            };

            var result = await new GetChartByCategoriesQuery(_context, command).Invoke(CancellationToken.None);

            Assert.NotNull(result);
            Assert.Equal(2, result.Length);
            Assert.Equal(30, result[0].Amount);
            Assert.Equal(10, result[1].Amount);
            Assert.Equal(1, result[0].CategoryId);
            Assert.Equal(2, result[1].CategoryId);
        }