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("")); }