// GET: Projects public ActionResult Index() { List <Project> model = new List <Project>(); if (User.IsInRole("Admin")) { model = db.Projects.Where(p => p.IsDeleted == false).ToList(); } else if (User.IsInRole("ProjectManager")) { var userId = User.Identity.GetUserId(); model = db.Projects.Where(p => p.ProjectManagerId == userId && p.IsDeleted == false).ToList(); } else if (User.IsInRole("Developer") || User.IsInRole("Submitter")) { var userId = User.Identity.GetUserId(); var user = db.Users.Find(userId); model = user.Projects.ToList(); } ProjectsIndexViewModel vm = new ProjectsIndexViewModel(); vm.Projects = model; return(View(vm)); }
// GET: Projects public async Task <IActionResult> Index(int?id) { var vm = new ProjectsIndexViewModel(); vm.Projects = await _uow.Projects.AllAsync(); //_context.Projects //.Include(i => i.ProjectType) //.Include(i => i.Positions) //.OrderByDescending(i => i.ProjectStartDate) //.AsNoTracking() //.ToListAsync(); if (id != null) { vm.SelectedProject = await _uow.Projects.GetSingle(id.Value); //_context.Projects.Where(i => i.ProjectId == id).SingleOrDefaultAsync(); vm.Positions = await _uow.Positions.GetPositionsForProject(id.Value); //_context.Positions.Where(i => i.ProjectId == id) //.Include(i => i.ApplicationUser) //.Include(i => i.PositionName) // .ThenInclude(i => i.PositionNameName) // .ThenInclude(i => i.Translations) //.AsNoTracking() //.ToListAsync(); vm.ProjectsId = id.Value; } return(View(vm)); }
// GET: Projects public ActionResult Index() { var projects = Context.Projects.OrderBy(pr => pr.CreatedAt).ToList(); var viewModel = new ProjectsIndexViewModel { Projects = projects }; return(View(viewModel)); }
// GET: Projects public async Task <IActionResult> Index(ProjectsIndexViewModel model) { model.Pager = new PagerViewModel(); model.Pager.CurrentPage = model.Pager.CurrentPage <= 0 ? 1 : model.Pager.CurrentPage; List <Project> items = await _context.Projects.Skip((model.Pager.CurrentPage - 1) *PageSize). Take(PageSize).Select(u => new Project() { Id = u.Id, ProjectName = u.ProjectName, Description = u.Description, WorkingTeams = u.WorkingTeams }).ToListAsync(); model.Items = items; model.Pager.PagesCount = (int)Math.Ceiling(await _context.Projects.CountAsync() / (double)PageSize); return(View(model)); }