public async Task <IActionResult> ChildrenByAge() { var user = await userManager.GetUserAsync(User); if (user == null || !(await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString()))) { return(Utilities.ErrorJson("Not authorized.")); } try { AnalyticsRepository repo = new AnalyticsRepository(configModel.ConnectionString); return(new JsonResult(new { ChildrenByAge = repo.GetChildrenByAge() })); } catch (Exception exc) { return(new JsonResult(new { Error = exc.Message, })); } }