Ejemplo n.º 1
0
        public IActionResult Create()
        {
            var companies = BuildCompanyList();
            var model     = new ProjectListingModel
            {
                ProjectType       = null,
                Status            = null,
                EndOfContractDate = null,
                Companies         = companies,
                SupportMembers    = BuildApplicationUserList()
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public IActionResult Index(int page = 1)
        {
            ProjectModel[] projects = this.projects.All(page)
                                      .ProjectTo <ProjectModel>()
                                      .ToArray();

            var result = new ProjectListingModel
            {
                Projects      = projects,
                TotalProjects = this.projects.Total(),
                CurrentPage   = page
            };

            return(Ok(result));
        }
Ejemplo n.º 3
0
        private ProjectListingModel BuildProjectForEdit(Project project)
        {
            var model = new ProjectListingModel
            {
                Id                        = project.Id,
                Code                      = project.Code,
                Name                      = project.Name,
                ProjectType               = project.ProjectType,
                CompanyId                 = project.Company.Id,
                Status                    = project.Status,
                EndOfContractDate         = project.EndOfContractDate,
                CreatedBy                 = project.CreatedBy.Id,
                CreatedDate               = project.CreationDate,
                Companies                 = BuildCompanyList(),
                ProjectContactPersons     = BuildCotactPersonForEdit(project.ProjectContacPersons),
                SupportMembers            = BuildApplicationUserList(),
                SupportPersonListingModel = BuildSupportPersonsForEdit(project.SupportMembers)
            };

            return(model);
        }
Ejemplo n.º 4
0
        public async Task <ProjectListingModel> FormatProjectAsync(Project project)
        {
            //Format project into Project Listing Model
            var listingResult = new ProjectListingModel
            {
                EfProject      = project,
                Id             = project.Id,
                Title          = project.Title,
                Description    = project.Description,
                CreateDate     = project.CreateDate,
                Creator        = project.Creator,
                LastUpdateDate = project.LastUpdateDate,
                LastUpdatedBy  = project.LastUpdatedBy
            };

            //Add a UserIndexModel of associated ApplicationUsers to Listing Model
            var appUsers     = new List <ApplicationUser>();
            var projectUsers = _context.ProjectUsers.Where(p => p.ProjectId == project.Id).ToList();

            for (int i = 0; i < projectUsers.Count; i++)
            {
                var user = await _userManager.FindByIdAsync(projectUsers[i].UserId);

                appUsers.Add(user);
            }
            listingResult.ProjectUsers.Users = await _userServices.FormatUsersAsync(appUsers);

            //Add list of associated Tickets to Listing Model
            var projectTickets = _ticketServices.GetAllByProjectId(project.Id).ToList();

            for (int i = 0; i < projectTickets.Count; i++)
            {
                listingResult.Tickets.Add(projectTickets[i]);
            }

            return(listingResult);
        }
Ejemplo n.º 5
0
        // GET: Projects
        public async Task <IActionResult> Index(string searchString)
        {
            try
            {
                ViewBag.ErrorMessage = TempData["ErrorMessage"].ToString();
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine(e.ToString());
            }
            var uid = (await _usermgr.GetUserAsync(User)).Id;
            ProjectListingModel model = new ProjectListingModel();

            if (User.IsInRole("AD"))
            {
                model.managedProjects = await _context.Projects.ToListAsync();

                model.assignedProjects = new List <Project>();
                return(View(model));
            }

            if (!String.IsNullOrEmpty(searchString))
            {
                model.managedProjects = await _context.ProjectEmployees
                                        .Where(pe => pe.EmployeeId == uid &&
                                               pe.WorkPackageId == null &&
                                               pe.Role != ProjectEmployee.NOT_ASSIGNED) // null WP is marker for mgmt roles
                                        .Join(_context.Projects,
                                              p => p.ProjectId,
                                              pe => pe.ProjectId,
                                              (pe, p) => p)
                                        .Where(p => p.Name.Contains(searchString) || p.ProjectCode.Contains(searchString))
                                        .ToListAsync();
            }
            else
            {
                model.managedProjects = await _context.ProjectEmployees
                                        .Where(pe => pe.EmployeeId == uid &&
                                               pe.WorkPackageId == null &&
                                               pe.Role != ProjectEmployee.NOT_ASSIGNED) // null WP is marker for mgmt roles
                                        .Join(_context.Projects,
                                              p => p.ProjectId,
                                              pe => pe.ProjectId,
                                              (pe, p) => p)
                                        .ToListAsync();
            }

            /*
             * THIS IS NOT DUPLICATE CODE, THEYRE TWO DIFFERENT LISTS!!!
             */
            if (!String.IsNullOrEmpty(searchString))
            {
                model.assignedProjects = await _context.ProjectEmployees
                                         .Where(pe => pe.EmployeeId == uid &&
                                                pe.WorkPackageId == null &&
                                                pe.Role != ProjectEmployee.PROJECT_MANAGER &&
                                                pe.Role != ProjectEmployee.PROJECT_ASSISTANT &&
                                                pe.Status == ProjectEmployee.CURRENTLY_WORKING) // null WP is marker for mgmt roles
                                         .Join(_context.Projects,
                                               p => p.ProjectId,
                                               pe => pe.ProjectId,
                                               (pe, p) => p)
                                         .Where(p => p.Name.Contains(searchString) || p.ProjectCode.Contains(searchString))
                                         .ToListAsync();
            }
            else
            {
                model.assignedProjects = await _context.ProjectEmployees
                                         .Where(pe => pe.EmployeeId == uid &&
                                                pe.WorkPackageId == null &&
                                                pe.Role != ProjectEmployee.PROJECT_MANAGER &&
                                                pe.Role != ProjectEmployee.PROJECT_ASSISTANT &&
                                                pe.Status == ProjectEmployee.CURRENTLY_WORKING) // null WP is marker for mgmt roles
                                         .Join(_context.Projects,
                                               p => p.ProjectId,
                                               pe => pe.ProjectId,
                                               (pe, p) => p)
                                         .ToListAsync();
            }

            return(View(model));
        }