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)); } }
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("")); }
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("")); }
public ManualCashFlowsController(FinPlannerContext context) { _context = context; }
public CFTypesController(FinPlannerContext context) { _context = context; }
public static void Initialize(FinPlannerContext context) { context.Database.EnsureCreated(); if (context.CFTypes.Any()) { return; } var cfTypes = new CFType[] { new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Salary" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Rent" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Groceries" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Electricty" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Loans" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Car Loan" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Insurance" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Bank Charges" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Domestic" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Cellphone" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Gym" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Internet" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Medical Aid" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Entertainment" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Takeout" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "School Fees" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Transportation" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = false, Name = "Medication" }, new CFType { Id = Guid.NewGuid().ToString(), Custom = true, ClientReference = "999", Name = "Transfer" } }; foreach (CFType item in cfTypes) { context.CFTypes.Add(item); } context.SaveChanges(); if (context.CFClassifications.Any()) { return; } var cfClass = new CFClassification[] { new CFClassification { Id = Guid.NewGuid().ToString(), Name = "Income", Sign = 1 }, new CFClassification { Id = Guid.NewGuid().ToString(), Name = "Expense", Sign = -1 }, }; foreach (CFClassification item in cfClass) { context.CFClassifications.Add(item); } context.SaveChanges(); }