Пример #1
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(""));
        }
Пример #2
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(""));
        }
Пример #3
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(""));
        }
Пример #4
0
        public ActionResult SafeToSpend(string collectionsId)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("SafeToSpend", true, false, "collectionsId " + collectionsId, auth.Identity.Name);
                return(Ok(new BudgetTransactionComparison(collectionsId)));
            }
            return(Ok(""));
        }
Пример #5
0
        public ActionResult GetClassification()
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("GetClassification", true, false, "", auth.Identity.Name);
                CFClassification cf = new CFClassification();
                return(Ok(cf.GetList()));
            }
            return(Ok(""));
        }
Пример #6
0
        public ActionResult GetCFType(string collectionsId)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("GetCFType", true, false, "collectionsId " + collectionsId, auth.Identity.Name);
                CFType cf = new CFType();
                return(Ok(cf.GetCFList(collectionsId).Where(x => x.Id != "39a1d903-f4e3-4e4a-986a-604bd8dff20e")));
            }
            return(Ok(""));
        }
Пример #7
0
        public ActionResult AccountDetails(string id)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("AccountDetails", true, false, "AccountId " + id, auth.Identity.Name);
                Account account = new Account();
                return(Ok(account.GetAccount(id, true)));
            }
            return(Ok(""));
        }
Пример #8
0
        public ActionResult SaveManualCashFlow([FromBody] JsonElement json)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("SaveManualCashFlow", false, true, json.GetRawText(), auth.Identity.Name);
                ManualCashFlow obj = JsonConvert.DeserializeObject <ManualCashFlow>(json.GetRawText());
                return(Ok(obj.Save()));
            }
            return(Ok(""));
        }
Пример #9
0
        public ActionResult BudgetEdit(string collectionsId)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("BudgetEdit", true, false, "collectionsId " + collectionsId, auth.Identity.Name);
                Collections collections = new Collections(collectionsId);
                return(Ok(collections));
            }
            return(Ok(""));
        }
Пример #10
0
        public ActionResult GetUnseenTransactions()
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("GetUnseenTransactions", true, false, "", auth.Identity.Name);
                UnseenModel unseen = new UnseenModel(auth.Identity.Name);
                return(Ok(unseen));
            }
            return(Ok(""));
        }
Пример #11
0
        public ActionResult getInstitutions()
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("getInstitutions", true, false, "", auth.Identity.Name);
                Institution institution = new Institution();
                return(Ok(institution.GetInstitutions()));
            }
            return(Ok(""));
        }
Пример #12
0
        public ActionResult GetAccountType()
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("GetAccountType", true, false, "", auth.Identity.Name);
                AccountType accountType = new AccountType();
                return(Ok(accountType.GetAccountTypes()));
            }
            return(Ok(""));
        }
Пример #13
0
        public ActionResult UnseenUpdate(string manualcashflow, [FromBody] JsonElement json)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("UnseenUpdate", false, true, json.GetRawText(), auth.Identity.Name);
                AutomatedCashFlow automatedCashFlow = JsonConvert.DeserializeObject <AutomatedCashFlow>(json.GetRawText());
                ReturnModel       returnModel       = automatedCashFlow.UpdateAutomated(manualcashflow);
                return(Ok(returnModel));
            }
            return(Ok(""));
        }
Пример #14
0
        //[ResponseType(typeof(ManualCashFlow))]
        public ActionResult NewCollection([FromBody] JsonElement json)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("NewCollection", false, true, json.GetRawText(), auth.Identity.Name);
                NewCollectionsObj obj         = JsonConvert.DeserializeObject <NewCollectionsObj>(json.GetRawText());
                Collections       collections = new Collections();
                return(Ok(collections.CreateCollection(obj)));
            }
            return(Ok(""));
        }
Пример #15
0
        public async Task <ActionResult> getYodleeToken(string collectionsId)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("GetYodleeToken", true, false, collectionsId, auth.Identity.Name);
                YodleeModel yodleeModel = new YodleeModel();
                string      token       = await yodleeModel.getToken(collectionsId, auth.Identity.Name);

                return(Ok(token));
            }
            return(Ok(""));
        }
Пример #16
0
        public ActionResult SetSharedCollection(string collectionId)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("SetSharedCollection", false, true, "collectionId " + collectionId, auth.Identity.Name);
                CollectionSharing collectionSharing = new CollectionSharing(collectionId);
                return(Ok(new ReturnModel()
                {
                    result = true, returnStr = collectionSharing.CollectionSharingId
                }));
            }
            return(Ok(""));
        }
Пример #17
0
        //[ResponseType(typeof(ManualCashFlow))]
        public ActionResult BudgetEdit([FromBody] JsonElement json)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("BudgetEdit", false, true, json.GetRawText(), auth.Identity.Name);
                string       str    = json.GetRawText();
                NewBudgetObj obj    = JsonConvert.DeserializeObject <NewBudgetObj>(str);
                Budget       budget = new Budget();
                bool         ans    = budget.Edit(obj);
                return(Ok(ans));
            }
            return(Ok(""));
        }
Пример #18
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(""));
        }
Пример #19
0
        public ActionResult GetTransactions(string id, DateTime startDate, DateTime endDate)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                GetTransactionsObj obj = new GetTransactionsObj()
                {
                    StartDate = startDate,
                    EndDate   = endDate,
                    Id        = id
                };
                ReportedTransaction        transaction  = new ReportedTransaction();
                List <ReportedTransaction> transactions = transaction.GetTransactions(obj.Id);
                transactions = transactions.Where(x => x.DateCaptured <= obj.EndDate && x.DateCaptured >= obj.StartDate).Where(x => x.CFType.Id != "999").OrderByDescending(x => x.DateBooked).ToList();
                return(Ok(transactions));
            }
            return(Ok(""));
        }
Пример #20
0
        public ActionResult AddAccount([FromBody] JsonElement json)
        {
            string          authHeader = this.HttpContext.Request.Headers["Authorization"];
            TokenModel      tokenModel = new TokenModel();
            ClaimsPrincipal auth       = tokenModel.GetPrincipal(authHeader);

            if (auth.Identity.IsAuthenticated)
            {
                new ClickTracker("AddAccount", false, true, json.GetRawText(), auth.Identity.Name);
                Account     account     = JsonConvert.DeserializeObject <Account>(json.GetRawText());
                ReturnModel returnModel = account.AddAccount(account);
                return(Ok(returnModel));
            }
            return(Ok(""));
            //[Route("BudgetEdit")]
            //[HttpGet]
            //public ActionResult BudgetEdit(string collectionsId, DateTime date)
            //{
            //    return Ok();
            //}
        }
Пример #21
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(""));
        }
Пример #22
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());
        }