public PartialViewResult _LatestProject() { using (MikeUpjohnCMSEntities db = new MikeUpjohnCMSEntities()) { //var project = db.Projects.OrderBy(x => x.ProjectPostDate).Take(1).SingleOrDefault(); ProjectsListViewModel project = (from x in db.Projects join y in db.Images on x.ProjectImageID equals y.ImageID into ya from y in ya.DefaultIfEmpty() join z in db.Images on x.ProjectThumbnailImageID equals z.ImageID into za from z in za.DefaultIfEmpty() orderby x.ProjectPostDate select new ProjectsListViewModel { ProjectID = x.ProjectID, ProjectTitle = x.ProjectTitle, ProjectDateDescription = x.ProjectDateDescription, ProjectPostDate = x.ProjectPostDate, ProjectSummary = x.ProjectSummary, ProjectDescription = x.ProjectDescription, ProjectLink = x.ProjectLink, ProjectImage = (y != null ? Settings.UPLOADSIMAGEFILEPATH + y.ImageFileName : Settings.DEFAULTIMAGEFILEPATH), ProjectThumbnailImage = (z != null ? Settings.UPLOADSIMAGEFILEPATH + z.ImageFileName : Settings.DEFAULTIMAGEFILEPATH), IsDisabled = x.IsDisabled, IsDeleted = x.IsDeleted, ProjectCreatedDate = x.ProjectCreatedDate }).FirstOrDefault(); return(PartialView(project)); } }
/// <summary> /// Lukas Schütz Created /// </summary> /// <returns></returns> public IActionResult List() { ProjectsListViewModel model = new ProjectsListViewModel(); model.LoadData(_unitOfWork); return(View(model)); }
// GET: /<controller>/ public ViewResult Index() { ProjectsListViewModel projectListViewModel = new ProjectsListViewModel(); projectListViewModel.Projects = _projectRepository.Projects; return(View(projectListViewModel)); }
public async Task <ActionResult> Search(string searchPhrase) { var searchProjectsTask = _apiRequestHandler.SearchProjects(searchPhrase); ProjectsListViewModel viewModel = new ProjectsListViewModel(); viewModel.Projects = await searchProjectsTask; return(View("List", viewModel)); }
public async Task <ActionResult> List(string searchPhrase, ProjectType projectsType = ProjectType.All) { var getProjectsTask = _apiRequestHandler.GetProjectsHeadersWithPriorityAndState(searchPhrase, projectsType); ProjectsListViewModel viewModel = new ProjectsListViewModel(); viewModel.Projects = await getProjectsTask; return(View(viewModel)); }
public async Task <IActionResult> Index() { var projects = new ProjectsListViewModel { ApprovedProjects = await this.projectsService.GetAllApprovedAsync <ProjectViewModel>(), NotApprovedProjects = await this.projectsService.GetAllNotApprovedAsync <ProjectViewModel>(), DeletedProjects = await this.projectsService.GetAllDeletedAsync <ProjectViewModel>(), }; return(this.View(projects)); }
public async Task <IActionResult> Index() { var currentUser = await this.userManager.GetUserAsync(this.User); var clientId = await this.clientsServices.GetClientIdByUserIdAsync(currentUser.Id); var allProjects = new ProjectsListViewModel { ApprovedProjects = await this.projectsService.GetAllApprovedByClientIdAsync <ProjectViewModel>(clientId), NotApprovedProjects = await this.projectsService.GetAllNotApprovedByClientIdAsync <ProjectViewModel>(clientId), }; return(this.View(allProjects)); }
public async Task <IActionResult> Index() { var projects = new ProjectsListViewModel(); try { var result = Ok(await Mediator.Send(new GetAllProjectsQuery())); projects = ((ProjectsListViewModel)result.Value); } catch (Exception e) { } return(View(projects)); }
public ActionResult Index() { //return View(db.Projects.ToList()); ProjectsListViewModel pListVM = new ProjectsListViewModel(); ICollection <Project> projects = db.Projects.ToList(); pListVM.AllProjects = projects; ViewBag.NoRolesAssigned = false; ICollection <ApplicationUser> unassignedUsers = db.Users.Where(u => u.Tickets.Count <= 0).ToList(); pListVM.DevelopersWithNoTicketAssignments = unassignedUsers; ICollection <ApplicationUser> usersWithNoRolesAssigned = db.Users.Where(u => u.Roles.Count <= 0).ToList(); pListVM.UsersWithNoRoles = usersWithNoRolesAssigned; List <ApplicationUser> tempUsers = new List <ApplicationUser>(); ApplicationUser tempUser = new ApplicationUser(); foreach (var project in pListVM.AllProjects) { tempUsers.Add(db.Users.FirstOrDefault(u => u.Id == project.AuthorId)); } // Admin Role does not need to be checked as all projects have already been passed to the VM. if (User.IsInRole("ProjectManager") || User.IsInRole("Developer") || User.IsInRole("Submitter")) { List <ApplicationUser> users = db.Users.ToList(); ApplicationUser user = users.First(u => u.Id == User.Identity.GetUserId()); pListVM.UserProjects = user.Projects.ToList(); foreach (var userProject in pListVM.UserProjects) { tempUser = db.Users.FirstOrDefault(u => u.Id == userProject.AuthorId); tempUsers.Add(tempUser); } } if (pListVM == null) { ViewBag.NoRolesAssigned = true; //If user has no role assignments, this will flag true. } pListVM.ProjectAuthors = tempUsers; return(View(pListVM)); }
public ProjectListPage() { //Set the view model of the page. Since this is the Projects List page, use that view model. var binding = new ProjectsListViewModel((IApplication)Application.Current); BindingContext = binding; InitializeComponent(); //when the page first appears, check if the user needs to login or not. Appearing += (sender, args) => { //if signed in already, the CurrentUser will not be null. if (LoginService.CurrentUser == null) { //send a message saying we need to login. MessagingCenter.Send(binding, "NeedsLogIn"); ToolbarItems.Add(new ToolbarItem("New Project", "plus.png", () => { })); } }; }
public ActionResult Projects() { var user = UserManager.FindById(User.Identity.GetUserId()); using (ApplicationDbContext context = new ApplicationDbContext()) { Org org = context.Orgs.Where(o => o.OrgID == user.OrgID).FirstOrDefault(); var projects = from prj in context.Projects where prj.OwnerID == org.OrgID select prj; ProjectsListViewModel viewModel = new ProjectsListViewModel(); foreach (var project in projects) { viewModel.Projects.Add(project); } return(View(viewModel)); } }
public ActionResult Index() { ProjectsListViewModel projectsListViewModel = new ProjectsListViewModel(); projectsListViewModel.List = new List <ProjectViewModel>(); ApplicationDbContext db = new ApplicationDbContext(); var nws = (from z in db.Projects select z).OrderByDescending(x => x.DateTimeCreated); foreach (var nw in nws) { ProjectViewModel projectViewModel = Mapper.Map <Project, ProjectViewModel>(nw); if (projectViewModel != null) { projectsListViewModel.List.Add(projectViewModel); } } return(View(projectsListViewModel)); }
public ActionResult Index() { //return View(db.Projects.ToList()); ProjectsListViewModel pListVM = new ProjectsListViewModel(); // Pull a list of all Projects and Tickets into a list and then assign them to the pListVM instance of the ViewModel ICollection <Project> allProjects = db.Projects.ToList(); ICollection <Ticket> allTickets = db.Tickets.ToList(); ICollection <Project> userProjects = allProjects.Where(p => p.Users.Any(z => z.Id == User.Identity.GetUserId())).ToList(); ICollection <Ticket> userTickets = allTickets.Where(t => t.AssignedUserId == User.Identity.GetUserId()).ToList(); ICollection <Ticket> submittedTickets = allTickets.Where(t => t.OwnerUserId == User.Identity.GetUserId()).ToList(); ICollection <ApplicationUser> developersWithNoTicketAssignments = db.Users.Where(u => (u.Roles.Any(r => r.RoleId == "f6c4f96d-cab2-4667-b3da-70b9165f344c")) && (u.Tickets.Count <= 0)).ToList(); ICollection <ApplicationUser> usersWithNoRolesAssigned = db.Users.Where(u => u.Roles.Count <= 0).ToList(); ICollection <ApplicationUser> allUsers = db.Users.ToList(); //ICollection<ApplicationUser> developers = db.Users.Where(u => (u.Roles.Any(r => r.RoleId == "f6c4f96d-cab2-4667-b3da-70b9165f344c"))).ToList(); pListVM.AllProjects = allProjects; pListVM.AllTickets = allTickets; pListVM.UserTickets = userTickets; pListVM.SubmittedTickets = submittedTickets; pListVM.DevelopersWithNoTicketAssignments = developersWithNoTicketAssignments; pListVM.UsersWithNoRoles = usersWithNoRolesAssigned; pListVM.AllUsers = allUsers; //pListVM.Developers = developers.ToArray(); //string[,] allProjectsTicketUserChartDataArray = new string[allProjects.Count(), 3]; //int i = 0; //foreach (Project project in allProjects) { // allProjectsTicketUserChartDataArray[i, 0] = project.Title; // allProjectsTicketUserChartDataArray[i, 1] = project.Tickets.Count().ToString(); // allProjectsTicketUserChartDataArray[i, 2] = project.Users.Count().ToString(); // i++; //} //pListVM.AllProjectsTicketUserChartDataArray = allProjectsTicketUserChartDataArray; //string[,] userProjectsTicketUserChartDataArray = new string[allProjects.Count(), 3]; //int j = 0; //foreach (Project userProject in userProjects) { // userProjectsTicketUserChartDataArray[j, 0] = userProject.Title; // userProjectsTicketUserChartDataArray[j, 1] = userProject.Tickets.Count().ToString(); // userProjectsTicketUserChartDataArray[j, 2] = userProject.Users.Count().ToString(); // i++; //} //pListVM.UserProjectsTicketUserChartDataArray = userProjectsTicketUserChartDataArray; //Dictionary<string, string[]> allProjectsTicketUserChartData = new Dictionary<string, string[]>(); //string[] tempArray = new string[2]; //foreach (Project project in allProjects) { // tempArray[0] = project.Tickets.Count().ToString(); // tempArray[1] = project.Users.Count().ToString(); // allProjectsTicketUserChartData.Add(project.Title, tempArray); //} //pListVM.AllProjectsTicketUserChartData = allProjectsTicketUserChartData; //Dictionary<string, string[]> userProjectsTicketUserChartData = new Dictionary<string, string[]>(); //foreach (Project userProject in userProjects) { // tempArray[0] = userProject.Tickets.Count().ToString(); // tempArray[1] = userProject.Users.Count().ToString(); // userProjectsTicketUserChartData.Add(userProject.Title, tempArray); //} //pListVM.UserProjectsTicketUserChartData = userProjectsTicketUserChartData; ViewBag.NoRolesAssigned = false; if (User.IsInRole("Developer") && pListVM.UserTickets == null) { ViewBag.NoRolesAssigned = true; //If user has no role assignments, this will flag true. } // I don't remember why I was pulling a list of Project Authors and cannot find where I used the information List <ApplicationUser> tempUsers = new List <ApplicationUser>(); ApplicationUser tempUser = new ApplicationUser(); foreach (var project in pListVM.AllProjects) { tempUsers.Add(db.Users.FirstOrDefault(u => u.Id == project.AuthorId)); } // Admin Role does not need to be checked as all projects have already been passed to the VM. if (User.IsInRole("ProjectManager") || User.IsInRole("Developer") || User.IsInRole("Submitter")) { List <ApplicationUser> users = db.Users.ToList(); ApplicationUser user = users.First(u => u.Id == User.Identity.GetUserId()); pListVM.UserProjects = user.Projects.ToList(); foreach (var userProject in pListVM.UserProjects) { tempUser = db.Users.FirstOrDefault(u => u.Id == userProject.AuthorId); tempUsers.Add(tempUser); } } pListVM.ProjectAuthors = tempUsers; return(View(pListVM)); }
public IActionResult List(ProjectsListViewModel model) { model.Projects = _unitOfWork.Projects.GetProjectByName(model.FilterProjectName); return(View(model)); }