示例#1
0
        public ActionResult GetIndex(string userId)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                AspNetUsers users = new AspNetUsers();
                new ClickTracker("GetIndex", true, false, "userId " + users.getUserId(userId), auth.Identity.Name);
                Collections                collection          = new Collections();
                List <Collections>         collections         = collection.GetCollections(userId, "TransactionList");
                List <ReportedTransaction> flows               = new List <ReportedTransaction>();
                ReportedTransaction        reportedTransaction = new ReportedTransaction();
                foreach (Collections item in collections)
                {
                    foreach (Account acc in item.Accounts)
                    {
                        flows.AddRange(reportedTransaction.GetTransactions(acc.Id));
                    }
                }
                return(Ok(flows));
            }
            return(Ok(""));
        }
        private ActionResult UnseenCount(string email)
        {
            int         count = 0;
            AspNetUsers users = new AspNetUsers();
            string      id    = users.getUserId(email);

            using (FinPlannerContext _context = new FinPlannerContext())
            {
                List <string> collections = _context
                                            .UserCollectionMapping
                                            .Where(x => x.Id == id)
                                            .Select(x => x.CollectionsId)
                                            .ToList();
                List <string> accounts = _context
                                         .Account
                                         .Where(Acc => collections.Contains(Acc.CollectionsId))
                                         .Select(x => x.Id)
                                         .ToList();
                foreach (string item in accounts)
                {
                    count = count + _context
                            .AutomatedCashFlows
                            .Where(auto => item.Contains(auto.AccountId))
                            .Where(x => x.Validated == false)
                            .Count();
                }
                return(Ok(count));
            }
        }
示例#3
0
        public ActionResult GetCFTypeUnseen()
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                AspNetUsers users = new AspNetUsers();
                string      id    = users.getUserId(auth.Identity.Name);
                using (FinPlannerContext _context = new FinPlannerContext())
                {
                    List <string> collections = _context
                                                .UserCollectionMapping
                                                .Where(x => x.Id == id)
                                                .Select(x => x.CollectionsId)
                                                .ToList();
                    List <CFType> types = new List <CFType>();
                    foreach (string item in collections)
                    {
                        CFType type = new CFType();
                        types.AddRange(type.GetCFList(item));
                    }
                    types = types
                            .GroupBy(x => x.Id)
                            .Select(g => g.First())
                            .ToList();
                    return(Ok(types));
                }
            }
            return(Ok(""));
        }
示例#4
0
        public ActionResult GetUser()
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                AspNetUsers users = new AspNetUsers();
                return(Ok(users.getUserId(auth.Identity.Name)));
            }
            return(Ok(""));
        }
示例#5
0
        public ActionResult GetUnseen()
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            ClaimsPrincipal auth       = new ClaimsPrincipal();
            TokenModel      tokenModel = new TokenModel();

            if (authHeader == "497633e2-8572-4711-8748-894ba8886b41")
            {
                authHeader = tokenModel.generateToken("*****@*****.**");
            }
            auth = tokenModel.GetPrincipal(authHeader);
            if (auth.Identity.IsAuthenticated)
            {
                int         count = 0;
                AspNetUsers users = new AspNetUsers();
                string      id    = users.getUserId(auth.Identity.Name);
                using (FinPlannerContext _context = new FinPlannerContext())
                {
                    List <string> collections = _context
                                                .UserCollectionMapping
                                                .Where(x => x.Id == id)
                                                .Select(x => x.CollectionsId)
                                                .ToList();
                    List <string> accounts = _context
                                             .Account
                                             .Where(Acc => collections.Contains(Acc.CollectionsId))
                                             .Select(x => x.Id)
                                             .ToList();
                    foreach (string item in accounts)
                    {
                        count = count + _context
                                .AutomatedCashFlows
                                .Where(auto => item.Contains(auto.AccountId))
                                .Where(x => x.Validated == false)
                                .Count();
                    }
                    return(Ok(count));
                }
            }
            return(Ok(""));
        }
示例#6
0
        public ActionResult CollectionsCount(string userId)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                AspNetUsers users = new AspNetUsers();
                new ClickTracker("CollectionsCount", true, false, "userId " + users.getUserId(userId), auth.Identity.Name);
                UserCollectionMapping mapping = new UserCollectionMapping();
                if (mapping.CollectionsCounter(userId) > 0)
                {
                    return(Ok(true));
                }
                else
                {
                    return(Ok(false));
                }
            }
            return(Ok(""));
        }
示例#7
0
        public ActionResult GetCollections(string type)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                AspNetUsers users = new AspNetUsers();
                new ClickTracker("GetCollections", true, false, "userId " + users.getUserId(auth.Identity.Name) + " type " + type, auth.Identity.Name);
                if (type == "Index")
                {
                    Collections        collection = new Collections();
                    List <Collections> list       = collection.GetCollections(auth.Identity.Name, type);
                    return(Ok(list));
                }
                else if (type == "Transactions")
                {
                    return(Ok());
                }
                return(Ok());
            }
            return(Ok());
        }