コード例 #1
0
 public UserCollectionMapping(string collectionsId, string userId)
 {
     try
     {
         AspNetUsers user = new AspNetUsers();
         userId = user.getUserId(userId);
     }
     catch
     {
         FirebaseUser user = new FirebaseUser();
         userId = user.GetFirebaseUser(userId);
     }
     if (CheckUser(collectionsId, userId))
     {
         UserCollectionMappingId = Guid.NewGuid().ToString();
         CollectionsId           = collectionsId;
         Id = userId;
     }
     else
     {
         UserCollectionMappingId = "999";
         CollectionsId           = "999";
         Id = "999";
     }
 }
コード例 #2
0
 public int CollectionsCounter(string userId)
 {
     using (FinPlannerContext _context = new FinPlannerContext())
     {
         AspNetUsers user = new AspNetUsers();
         string      id   = user.getUserId(userId);
         return(_context.UserCollectionMapping.Where(x => x.Id == id).Count());
     }
 }
コード例 #3
0
        private Collections(string durationType, string name, string userId, int resetDate)
        {
            CollectionsId = Guid.NewGuid().ToString();
            Name          = name;
            DurationType  = durationType;
            AspNetUsers user = new AspNetUsers();

            UserCreated = user.getUserId(userId);
            DateCreated = DateTime.Now;
            ResetDay    = resetDate;
        }
コード例 #4
0
        public ClickTracker(string location, bool get, bool post, string data, string userId)
        {
            ClickTrackerId = Guid.NewGuid().ToString();
            AspNetUsers user = new AspNetUsers();

            UserId         = user.getUserId(userId);
            Location       = location;
            GET            = get;
            POST           = post;
            RecordDateTime = DateTime.Now;
            RequestData    = data;
            Save(this);
        }
コード例 #5
0
        /// <summary>
        /// The landing page is made up of a series of object this returns a list of the collection ojects high level details
        /// </summary>
        /// <param name="email">Users email address</param>
        /// <returns>Returns a list of index model objetcts</returns>
        public List <IndexModel> GetModel(string email)
        {
            List <IndexModel>     model         = new List <IndexModel>();
            List <string>         collectionIds = new List <string>();
            UserCollectionMapping mapping       = new UserCollectionMapping();
            string userId = "";

            try
            {
                FirebaseUser user = new FirebaseUser();
                userId        = user.GetFirebaseUser(email);
                collectionIds = mapping.getCollectionIds(userId, "firebase");
            }
            catch
            {
                AspNetUsers user = new AspNetUsers();
                userId        = user.getUserId(email);
                collectionIds = mapping.getCollectionIds(userId, "asp");
            }
            Collections        collection  = new Collections();
            Account            account     = new Account();
            Budget             budget      = new Budget();
            List <Collections> collections = collection.GetEagerList(collectionIds);

            foreach (Collections item in collections)
            {
                try
                {
                    IndexModel temp = new IndexModel();
                    temp.Name          = item.Name;
                    temp.CollectionsId = item.CollectionsId;
                    temp.Avaialble     = account.GetAvaialable(item.CollectionsId);
                    temp.Budgeted      = Math.Round(budget.GetBudgetedAmount(item.CollectionsId), 2).ToString("N2");
                    temp.Used          = Math.Round(budget.GetSpentAmount(item.CollectionsId), 2).ToString("N2");
                    temp.isShared      = mapping.IsShared(item.CollectionsId);
                    model.Add(temp);
                }
                catch (Exception e)
                {
                    ExceptionCatcher catcher = new ExceptionCatcher();
                    catcher.Catch(e.Message);
                }
            }
            return(model);
        }
コード例 #6
0
        public ManualCashFlow(ManualCashFlow flow)
        {
            AspNetUsers users = new AspNetUsers();

            CFTypeId           = flow.CFTypeId;
            CFClassificationId = flow.CFClassificationId;
            Amount             = flow.Amount;
            DateBooked         = flow.DateBooked;
            DateCaptured       = DateTime.Now;
            SourceOfExpense    = flow.SourceOfExpense;
            Expected           = flow.Expected;
            Id              = Guid.NewGuid().ToString();
            UserId          = users.getUserId(flow.UserId);
            isDeleted       = false;
            ExpenseLocation = flow.ExpenseLocation;
            AccountId       = flow.AccountId;
            Description     = flow.Description;
            ExpenseLocation = flow.ExpenseLocation;
        }
コード例 #7
0
        public UnseenModel(string userId)
        {
            AspNetUsers users = new AspNetUsers();
            string      id    = users.getUserId(userId);

            using (FinPlannerContext _context = new FinPlannerContext())
            {
                List <string> collections = _context
                                            .UserCollectionMapping
                                            .Where(x => x.Id == id)
                                            .Select(x => x.CollectionsId)
                                            .ToList();
                List <string> accountsStr = _context
                                            .Account
                                            .Where(Acc => collections.Contains(Acc.CollectionsId))
                                            .Select(x => x.Id)
                                            .ToList();
                Account account = new Account();
                Accounts = new List <Account>();
                foreach (string item in collections)
                {
                    Accounts
                    .AddRange(account.GetAccounts(item));
                }
                AutomatedCashFlow automatedCash  = new AutomatedCashFlow();
                ManualCashFlow    manualCash     = new ManualCashFlow();
                CFType            type           = new CFType();
                CFClassification  classification = new CFClassification();
                AutomatedCashFlows = automatedCash
                                     .GetAutomatedCashFlowsUnseen(accountsStr);
                ManualCashFlows = manualCash
                                  .GetManualCahFlowsUnseen(accountsStr);
                CFTypes = type
                          .GetCFList(collections)
                          .GroupBy(x => x.Id)
                          .Select(x => x.First())
                          .ToList();
                CFClassifications = classification
                                    .GetList();
            }
        }
コード例 #8
0
        public BudgetTransaction(BudgetTransaction b, string budgetId, string collectionsId)
        {
            BudgetTransactionId = Guid.NewGuid().ToString();
            BudgetId            = budgetId;
            Amount = b.Amount;
            Name   = b.Name;
            CFType        type = new CFType();
            List <CFType> list = type.GetCFList(collectionsId);

            if (list.Any(x => x.Id == b.CFTypeId))
            {
                CFTypeId = b.CFTypeId;
            }
            else
            {
                type     = type.CreateCFType(collectionsId, b.CFTypeId);
                CFTypeId = type.Id;
            }
            CFClassificationId = b.CFClassificationId;
            AspNetUsers users = new AspNetUsers();

            try
            {
                UserId = users.getUserId(b.UserId);
            }
            catch
            {
                FirebaseUser user = new FirebaseUser();
                FirebaseUserId = user.GetFirebaseUser(UserId);
            }
            //using (FinPlannerContext _context = new FinPlannerContext())
            //{
            //	CFType = _context.CFTypes.Find(CFTypeId);
            //	CFClassification = _context.CFClassifications.Find(CFClassificationId);
            //}
        }
コード例 #9
0
        public List <Collections> GetCollections(string userId, string type)
        {
            List <Collections> collections = new List <Collections>();

            if (userId != "")
            {
                AspNetUsers user = new AspNetUsers();
                userId = user.getUserId(userId);
                if (type != "Index")
                {
                    using (FinPlannerContext _context = new FinPlannerContext())
                    {
                        List <string> collectionIds = _context.UserCollectionMapping
                                                      .Where(x => x.Id == userId)
                                                      .Select(x => x.CollectionsId)
                                                      .ToList();
                        foreach (string item in collectionIds)
                        {
                            switch (type)
                            {
                            case "Accounts":
                                collections.Add(new Collections(_context.Collections.Find(item), 0, type));
                                break;

                            case "TransactionList":
                                collections.Add(new Collections(_context.Collections.Find(item), 10, type));
                                break;

                            case "TransactionCount":
                                collections.Add(new Collections(_context.Collections.Find(item), 1000, type));
                                break;

                            default:
                                collections.Add(_context.Collections.Find(item));
                                break;
                            }
                        }
                    }
                    return(collections);
                }
                else
                {
                    using (FinPlannerContext _context = new FinPlannerContext())
                    {
                        List <string> collectionsIds = _context.UserCollectionMapping
                                                       .Where(x => x.Id == userId)
                                                       .Select(x => x.CollectionsId)
                                                       .ToList();
                        collections.AddRange(GetCollections(collectionsIds, 10));
                        return(collections);
                    }
                }
            }
            else
            {
                using (FinPlannerContext _context = new FinPlannerContext())
                {
                    collections = _context
                                  .Collections
                                  .ToList();
                }
                Account account = new Account();
                foreach (Collections item in collections)
                {
                    item.Accounts = account.GetAccounts(item.CollectionsId);
                }
                //what does this do? Who involes it?
                Budget budget = new Budget();
                foreach (Collections item in collections)
                {
                    item.Budgets = budget.GetBudgets(item.CollectionsId);
                }
                return(collections);
            }
        }