public Project GetProject(int projectId)
        {
            var data = ProjectProcessor.GetProject(projectId);

            Project = new Project( )
            {
                ProjectId          = data.ProjectId,
                Name               = data.Name,
                ProjectRoleGroupId = data.ProjectRoleGroupId
            };
            return(Project);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int?id)
        {
            // Make sure the user is logged in and that they have permission
            if (!IsUserLoggedIn)
            {
                return(RedirectToLogin());
            }
            if (!UserHasPermission(PermissionName.Project))
            {
                return(RedirectToPermissionDenied());
            }

            // Check if a project ID was provided
            if (id == null)
            {
                return(RedirectToIndex());
            }
            int projectId = (int)id;

            // Entry try-catch from here
            // Make sure any errors are displayed
            try
            {
                // Get the project data
                var projectModel = ProjectProcessor.GetProject(projectId);
                if (projectModel == null)
                {
                    return(RedirectToIndexIdNotFound(projectId));
                }

                // Get all project role groups from the database
                var projectRoleGroupModels = ProjectRoleGroupProcessor.GetAllProjectRoleGroups();

                // Get list of available project role groups
                // Store it in a list for a drop-down-list
                ViewBag.RoleGroup = new SelectList(projectRoleGroupModels, "ProjectRoleGroupId", "Name", projectModel.ProjectRoleGroupId);

                // Convert the model data to non-model data
                // Pass the data to the view
                return(View(new Project(projectModel, projectRoleGroupModels)));
            }
            catch (Exception e)
            {
                return(RedirectToIndex(e));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Details(int?id)
        {
            // Make sure the user is logged in and that they have permission
            if (!IsUserLoggedIn)
            {
                return(RedirectToLogin());
            }
            if (!UserHasPermission(PermissionName.Project))
            {
                return(RedirectToPermissionDenied());
            }

            // Check if a project ID was provided
            if (id == null)
            {
                return(RedirectToIndex());
            }
            int projectId = (int)id;

            // Entry try-catch from here
            // Make sure any errors are displayed
            try
            {
                // Get the project data
                var projectModel = ProjectProcessor.GetProject(projectId);
                if (projectModel == null)
                {
                    return(RedirectToIndexIdNotFound(projectId));
                }

                // Get name of assigned project role group
                var roleGroup = ProjectRoleGroupProcessor.GetProjectRoleGroup(projectModel.ProjectRoleGroupId);

                //var teams = TeamProcessor.SelectTeamsForUnitOfferingId( projectId );

                // Convert the model data to non-model data
                // Pass the data to the view
                return(View(new Project(projectModel, roleGroup)));
            }
            catch (Exception e)
            {
                return(RedirectToIndex(e));
            }
        }
        public ActionResult Details(int?id)
        {
            // Make sure the user is logged in and that they have permission
            if (!IsUserLoggedIn)
            {
                return(RedirectToLogin());
            }
            if (!UserHasPermission(PermissionName.ProjectOffering))
            {
                return(RedirectToPermissionDenied());
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            try
            {
                int projectOfferingId    = ( int )id;
                var projectOfferingModel = ProjectOfferingProcessor.SelectProjectOfferingForProjectOfferingId(projectOfferingId);
                if (projectOfferingModel == null)
                {
                    return(RedirectToIndexIdNotFound(projectOfferingId));
                }

                var project = ProjectProcessor.GetProject(projectOfferingModel.ProjectId);

                var unitOffering = UnitOfferingProcessor.SelectUnitOfferingForUnitOfferingId(projectOfferingModel.UnitOfferingId);

                var teams = TeamProcessor.SelectTeamsForProjectOfferingId(projectOfferingModel.ProjectOfferingId);

                var projectOffering = new ProjectOffering(projectOfferingModel, project, unitOffering, teams);

                return(View(projectOffering));
            }
            catch (Exception e)
            {
                return(RedirectToIndex(e));
            }
        }
Ejemplo n.º 5
0
        public ActionResult Delete(int?id)
        {
            // Make sure the user is logged in and that they have permission
            if (!IsUserLoggedIn)
            {
                return(RedirectToLogin());
            }
            if (!UserHasPermission(PermissionName.Project))
            {
                return(RedirectToPermissionDenied());
            }

            // Check if a project ID was provided
            if (id == null)
            {
                return(RedirectToIndex());
            }
            int projectId = (int)id;

            // Entry try-catch from here
            // Make sure any errors are displayed
            try
            {
                // Get the project data
                var projectModel = ProjectProcessor.GetProject(projectId);
                if (projectModel == null)
                {
                    return(RedirectToIndexIdNotFound(projectId));
                }

                // Convert the model data to non-model data
                // Pass the data to the view
                return(View(new Project(projectModel)));
            }
            catch (Exception e)
            {
                return(RedirectToIndex(e));
            }
        }
Ejemplo n.º 6
0
        private void GetProjectOffering(int id)
        {
            var data = ProjectOfferingProcessor.SelectProjectOfferingForProjectOfferingId(id);

            ProjectOffering = new ProjectOffering( )
            {
                ProjectOfferingId = data.ProjectOfferingId,
                ProjectId         = data.ProjectId,
                UnitOfferingId    = data.UnitOfferingId
            };

            var projectData = ProjectProcessor.GetProject(data.ProjectId);

            ProjectOffering.Project = new Project( )
            {
                ProjectId          = projectData.ProjectId,
                ProjectRoleGroupId = projectData.ProjectRoleGroupId,
                Name = projectData.Name
            };

            var unitOfferingData = UnitOfferingProcessor.SelectUnitOfferingForUnitOfferingId(data.UnitOfferingId);

            ProjectOffering.UnitOffering = new UnitOffering( )
            {
                UnitOfferingId   = unitOfferingData.UnitOfferingId,
                TeachingPeriodId = unitOfferingData.TeachingPeriodId,
                YearId           = unitOfferingData.YearId,
                ConvenorId       = unitOfferingData.ConvenorId,
                UnitId           = unitOfferingData.UnitId,
            };

            var teachingperiodData = TeachingPeriodProcessor.SelectTeachingPeriodForTeachingPeriodId(ProjectOffering.UnitOffering.TeachingPeriodId);

            ProjectOffering.UnitOffering.TeachingPeriod = new TeachingPeriod( )
            {
                TeachingPeriodId = teachingperiodData.TeachingPeriodId,
                Name             = teachingperiodData.Name,
                Day   = teachingperiodData.Day,
                Month = teachingperiodData.Month
            };
            var yearData = YearProcessor.SelectYearForYearId(ProjectOffering.UnitOffering.YearId);

            ProjectOffering.UnitOffering.Year = new Year( )
            {
                YearId    = yearData.YearId,
                YearValue = yearData.Year
            };

            var convenorData = UserProcessor.SelectUserForUserId(ProjectOffering.UnitOffering.ConvenorId);

            ProjectOffering.UnitOffering.Convenor = new User( )
            {
                UserId   = convenorData.UserId,
                Username = convenorData.Username
            };

            var unitData = UnitProcessor.SelectUnitForUnitId(ProjectOffering.UnitOffering.UnitId);

            ProjectOffering.UnitOffering.Unit = new Unit( )
            {
                UnitId = unitData.UnitId,
                Name   = unitData.Name
            };
        }