예제 #1
0
        public ActionResult AccountList()
        {
            GetAccounts    g        = new GetAccounts();
            List <Account> accounts = g.A().OrderBy(x => x.AccountNumber).ToList();

            return(View(accounts));
        }
예제 #2
0
        public ActionResult ProfitAndLoss(IFormCollection forms)
        {
            string personid = forms["PersonID"];
            string firstday = forms["firstDay"];
            string lastday  = forms["lastDay"];

            ViewBag.firstday = firstday;
            ViewBag.lastday  = lastday;
            ViewBag.personid = personid;

            List <Transaction> transactions = context.db.GetCollection <Transaction>("Transactions")
                                              .AsQueryable().ToList();

            List <Transaction> filteredtransactions = transactions.AsQueryable()
                                                      .Where(x => x.TransactionDate >= Convert.ToDateTime(firstday))
                                                      .Where(x => x.TransactionDate <= Convert.ToDateTime(lastday)).ToList();

            GetAccounts    g        = new GetAccounts();
            List <Account> accounts = g.A().Where(c => c.AccountPerson.AccountPerson1 == personid)
                                      .Where(x => x.Active == true).ToList();

            List <FilteredTransactions> ta = filteredtransactions
                                             .Join(accounts, t => t.AccountNumber1, a => a.AccountNumber, (t, a) =>
                                                   new FilteredTransactions {
                AccountNumber  = t.AccountNumber1,
                AccountName    = a.AccountName,
                AccountSubType = a.AccountSubType.AccountSubType1,
                SortOrder      = a.AccountSubType.SortOrder,
                AccountType    = a.AccountSubType.AccountType.AccountType1,
                Total          = t.Account1Amount,
                Count          = 1,
                AccountPerson  = a.AccountPerson.AccountPerson1
            }).ToList();

            List <FilteredTransactions> AGroup = ta
                                                 .GroupBy(s => s.AccountNumber)
                                                 .Select(group => new FilteredTransactions {
                AccountNumber  = group.First().AccountNumber,
                AccountName    = group.First().AccountName,
                AccountSubType = group.First().AccountSubType,
                SortOrder      = group.First().SortOrder,
                AccountType    = group.First().AccountType,
                Total          = group.Sum(s => s.Total),
                Count          = group.Count(),
                AccountPerson  = group.First().AccountPerson
            }).ToList();

            List <FilteredTransactions> ASTGroup = ta
                                                   .GroupBy(s => s.AccountSubType)
                                                   .Select(group => new FilteredTransactions {
                AccountNumber  = null,
                AccountName    = "Total",
                AccountSubType = group.First().AccountSubType,
                SortOrder      = group.First().SortOrder,
                AccountType    = group.First().AccountType,
                Total          = group.Sum(s => s.Total),
                Count          = group.Count(),
                AccountPerson  = group.First().AccountPerson
            }).ToList();

            List <FilteredTransactions> ATGroup = ta
                                                  .GroupBy(s => s.AccountType)
                                                  .Select(group => new FilteredTransactions {
                AccountNumber  = null,
                AccountName    = "",
                AccountSubType = "Total",
                SortOrder      = 999,
                AccountType    = group.First().AccountType,
                Total          = group.Sum(s => s.Total),
                Count          = group.Count(),
                AccountPerson  = group.First().AccountPerson
            }).ToList();

            List <FilteredTransactions> listFinal = AGroup.Union(ASTGroup).Union(ATGroup)
                                                    .OrderByDescending(x => x.AccountType)
                                                    .ThenBy(x => x.SortOrder).ToList();

            return(View(listFinal));
        }