Beispiel #1
0
        // GET: Transactions/Details/
        public ActionResult TransactionDetails(string id, string personid, string firstday, string lastday)
        {
            MongoDB.Bson.BsonObjectId myId = new BsonObjectId(ObjectId.Parse(id));
            var trans = context.db.GetCollection <Transaction>("Transactions")
                        .Aggregate()
                        .Match(x => x.Id == myId)
                        .Lookup("Accounts", "AccountNumber1", "AccountNumber", "Account_docs").ToList();
            List <TransactionsWithAccounts> myColl = new List <TransactionsWithAccounts>();

            foreach (BsonDocument bd in trans)
            {
                TransactionsWithAccounts ta = BsonSerializer.Deserialize <TransactionsWithAccounts>(bd);
                myColl.Add(ta);
            }
            ViewBag.firstday = firstday;
            ViewBag.lastday  = lastday;
            ViewBag.personid = personid;
            return(View(myColl[0]));
        }
Beispiel #2
0
        public List <TransactionsWithAccounts> TA(string firstDay, string lastDay, string personid)
        {
            DateTime fromDate = Convert.ToDateTime(firstDay);
            DateTime toDate   = Convert.ToDateTime(lastDay);
            var      trans    = context.db.GetCollection <Transaction>("Transactions")
                                .Aggregate()
                                .Lookup("Accounts", "AccountNumber1", "AccountNumber", "Account_docs").ToList();
            List <TransactionsWithAccounts> myColl = new List <TransactionsWithAccounts>();

            foreach (BsonDocument bd in trans)
            {
                TransactionsWithAccounts ta = BsonSerializer.Deserialize <TransactionsWithAccounts>(bd);
                myColl.Add(ta);
            }
            var result =
                myColl.AsQueryable()
                .Where(x => x.TransactionDate >= fromDate)
                .Where(x => x.TransactionDate <= toDate)
                .Where(x => x.Account_docs.Select(user => user.AccountPerson.AccountPerson1).Contains(personid))
                .Where(x => x.Account_docs.Select(user => user.Active).Contains(true))
                .OrderBy(x => x.TransactionDate);

            return(result.ToList());
        }