public async Task <IActionResult> Index() { ApplicationUser user = await GetCurrentUser(); bool isAdmin = await IsAdmin(user); IIncludableQueryable <Opportunity, Organization> opportunitiesQueryable = _context.Opportunities .Include(o => o.Category) .Include(o => o.Community) .Include(o => o.Organization); List <Opportunity> opportunities; if (isAdmin) { opportunities = await opportunitiesQueryable .ToListAsync(); } else { opportunities = await opportunitiesQueryable .Where(o => o.CreatedByUserId == user.Id) .ToListAsync(); } return(View(opportunities)); }
// GET: ProjectUsers public async Task <IActionResult> Index( ) { IIncludableQueryable <ProjectUser, HeimdallUser> applicationDbContext = this.context.ProjectUsers.Include(p => p.Project).Include(p => p.User); return(this.View(await applicationDbContext.ToListAsync( ).ConfigureAwait(false))); }
public async Task <IActionResult> Index() { IIncludableQueryable <Models.Task, Project> vPMDBContext = _context.Task.Include(t => t.Project); List <Models.Task> tasks = await vPMDBContext.ToListAsync(); return(View(tasks)); }
// GET: TicketAttachments public async Task <IActionResult> Index( ) { IIncludableQueryable <TicketAttachment, HeimdallUser> applicationDbContext = this.context.TicketAttachments .Include(t => t.Ticket) .Include(t => t.User); return(this.View(await applicationDbContext.ToListAsync( ).ConfigureAwait(false))); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="cap"></param> /// <returns></returns> public static async Task <List <PatientJournal> > GetJournalsWithChildren(this AerendeContext context, int cap) { IIncludableQueryable <PatientJournal, Adress> patientJournals = context.GetChildrenInQuery(); Task <List <PatientJournal> > patientJournlas_WithOrWithOutCap = cap == 0 ? patientJournals.ToListAsync() : patientJournals.Take(cap).ToListAsync(); return(await patientJournlas_WithOrWithOutCap); }
// GET: Tickets public async Task <IActionResult> Index( ) { IIncludableQueryable <Ticket, TicketType> applicationDbContext = this.context.Tickets .Include(t => t.DeveloperUser) .Include(t => t.OwnerUser) .Include(t => t.Project) .Include(t => t.TicketPriority) .Include(t => t.TicketStatus) .Include(t => t.TicketType); return(this.View(await applicationDbContext.ToListAsync( ).ConfigureAwait(false))); }
public async Task <IEnumerable <Recipe> > Sort(string sorter, IIncludableQueryable <Recipe, Category> recipes) { switch (sorter) { case "AZ": var az = from recipe in recipes orderby recipe.RecipeName ascending select recipe; return(await az.ToListAsync()); case "ZA": var za = from recipe in recipes orderby recipe.RecipeName descending select recipe; return(await za.ToListAsync()); case "Longest": var longest = from recipe in recipes orderby recipe.RecipeDuration descending select recipe; return(await longest.ToListAsync()); case "Shortest": var shortest = from recipe in recipes orderby recipe.RecipeDuration ascending select recipe; return(await shortest.ToListAsync()); case "Rating": var rating = from recipe in recipes orderby recipe.RecipeRating descending select recipe; return(await rating.ToListAsync()); case "Favorited": var favorited = from recipe in recipes where recipe.RecipeFavorited == true select recipe; return(await favorited.ToListAsync()); default: return(await recipes.ToListAsync()); } }
// GET: Grades public async Task <IActionResult> Index() { IIncludableQueryable <Grades, User> grades = null; if (User.IsInRole("Admin")) { grades = _context.Grades.Include(g => g.Exams).Include(g => g.Student); } else if (User.IsInRole("Teacher")) { var user = await _userManager.FindByEmailAsync(User.Identity.Name); grades = _context.Grades.Where(g => g.Exams.Course.TeacherId == user.Id).Include(g => g.Exams).Include(g => g.Student); } else { var user = await _userManager.FindByEmailAsync(User.Identity.Name); grades = _context.Grades.Where(g => g.StudentId == user.Id && g.IsPublished).Include(g => g.Exams).Include(g => g.Student); } return(View(await grades.ToListAsync())); }
// GET: Enrollments public async Task <IActionResult> Index() { IIncludableQueryable <Enrollment, User> enrollments = null; if (User.IsInRole("Admin")) { enrollments = _context.Enrollments.Include(e => e.Course).Include(e => e.Student); } else if (User.IsInRole("Teacher")) { var user = await _userManager.FindByEmailAsync(User.Identity.Name); enrollments = _context.Enrollments.Where(e => e.Course.TeacherId == user.Id).Include(e => e.Course).Include(e => e.Student); } else { var user = await _userManager.FindByEmailAsync(User.Identity.Name); enrollments = _context.Enrollments.Where(e => e.StudentId == user.Id).Include(e => e.Course).Include(e => e.Student); } return(View(await enrollments.ToListAsync())); }
// GET: Sessions public async Task <IActionResult> Index() { IIncludableQueryable <Session, Course> sessions = null; if (User.IsInRole("Admin")) { sessions = _context.Sessions.Include(s => s.Course); } else if (User.IsInRole("Teacher")) { var user = await _userManager.FindByEmailAsync(User.Identity.Name); sessions = _context.Sessions.Where(s => s.Course.TeacherId == user.Id).Include(s => s.Course); } else { var user = await _userManager.FindByEmailAsync(User.Identity.Name); var enrollments = _context.Enrollments.Where(e => e.StudentId == user.Id).Select(e => e.CourseId).ToList(); sessions = _context.Sessions.Where(s => enrollments.Contains(s.CourseId)).Include(s => s.Course); } return(View(await sessions.ToListAsync())); }
// GET: Stat/Games public async Task <IActionResult> Index() { IIncludableQueryable <Game, IdentityUser> applicationDbContext = _context.Games.Include(g => g.User1).Include(g => g.User2); var sql = applicationDbContext.ToString(); String temp = applicationDbContext.ToSql(); List <Game> games = await applicationDbContext.ToListAsync(); //games.ForEach(x => //{ // GameModel gm = (GameModel)x; // gm.User1Email = "em1"; // gm.User2Email = "em2"; // models.Add(gm); //}); return(View(games)); }
// GET: Users public async Task <IActionResult> Index() { IIncludableQueryable <User, UserRole> dataBaseContext = _context.Users.Include(u => u.UserRole); return(View(await dataBaseContext.ToListAsync())); }
// GET: Products public async Task <IActionResult> Index() { IIncludableQueryable <Product, Category> gcpLoggingContext = _context.Product.Include(p => p.Category); return(View(await gcpLoggingContext.ToListAsync())); }