public ProjectOffering GetProjectOffering(int projectOfferingId)
        {
            var data = ProjectOfferingProcessor.SelectProjectOfferingForProjectOfferingId(projectOfferingId);

            ProjectOffering = new ProjectOffering( )
            {
                ProjectOfferingId = data.ProjectOfferingId,
                ProjectId         = data.ProjectId,
                UnitOfferingId    = data.UnitOfferingId
            };
            ProjectOffering.Project      = GetProject(data.ProjectId);
            ProjectOffering.UnitOffering = GetUnitOffering(data.UnitOfferingId);

            return(ProjectOffering);
        }
        public List <ProjectOffering> GetProjectOfferings( )
        {
            var data = ProjectOfferingProcessor.SelectProjectOfferings( );

            ProjectOfferings = new List <ProjectOffering>( );
            foreach (var row in data)
            {
                var projectOffering = new ProjectOffering( )
                {
                    ProjectOfferingId = row.ProjectOfferingId,
                    ProjectId         = row.ProjectId,
                    UnitOfferingId    = row.ProjectId
                };
                projectOffering.Project      = GetProject(row.ProjectId);
                projectOffering.UnitOffering = GetUnitOffering(row.UnitOfferingId);

                ProjectOfferings.Add(projectOffering);
            }
            return(ProjectOfferings);
        }
예제 #3
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
            };
        }
        //public UnitOffering( TCABS_DataLibrary.Models.UnitOfferingModel unitOfferingModel )
        //{
        //   UnitOfferingId = unitOfferingModel.UnitOfferingId;
        //   ConvenorId = unitOfferingModel.ConvenorId;
        //   UnitId = unitOfferingModel.UnitId;
        //   TeachingPeriodId = unitOfferingModel.TeachingPeriodId;
        //   YearId = unitOfferingModel.YearId;

        //   Enrollments = new HashSet<Enrollment>( );
        //   ProjectOfferings = new HashSet<Team>( );
        //}

        public UnitOffering(TCABS_DataLibrary.Models.UnitOfferingModel unitOffering,
                            TCABS_DataLibrary.Models.UnitModel unit,
                            TCABS_DataLibrary.Models.TeachingPeriodModel teachingperiod,
                            TCABS_DataLibrary.Models.YearModel year,
                            TCABS_DataLibrary.Models.UserModel convenor,
                            List <TCABS_DataLibrary.Models.ProjectOfferingModel> projectOfferings,
                            List <TCABS_DataLibrary.Models.EnrollmentModel> enrollments)
        {
            UnitOfferingId   = unitOffering.UnitOfferingId;
            UnitId           = unitOffering.UnitId;
            TeachingPeriodId = unitOffering.TeachingPeriodId;
            YearId           = unitOffering.YearId;
            ConvenorId       = unitOffering.ConvenorId;

            Unit = new Unit( );
            if (unit?.UnitId == UnitId)
            {
                Unit.Name   = unit.Name;
                Unit.UnitId = unit.UnitId;
            }

            TeachingPeriod = new TeachingPeriod( );
            if (teachingperiod?.TeachingPeriodId == TeachingPeriodId)
            {
                TeachingPeriod.Name             = teachingperiod.Name;
                TeachingPeriod.Month            = teachingperiod.Month;
                TeachingPeriod.Day              = teachingperiod.Day;
                TeachingPeriod.TeachingPeriodId = teachingperiod.TeachingPeriodId;
            }

            Year = new Year( );
            if (year?.YearId == YearId)
            {
                Year.YearValue = year.Year;
                Year.YearId    = year.YearId;
            }

            Convenor = new User( );
            if (convenor?.UserId == ConvenorId)
            {
                Convenor.Username = convenor.Username;
                Convenor.UserId   = convenor.UserId;
            }

            ProjectOfferings = new List <ProjectOffering>( );

            foreach (var po in projectOfferings)
            {
                var projectOffering = new ProjectOffering( )
                {
                    ProjectOfferingId = po.ProjectOfferingId,
                    UnitOfferingId    = po.UnitOfferingId,
                    ProjectId         = po.ProjectId
                };
                projectOffering.UnitOffering = this;
                //var supervisorModel = UserProcessor.SelectUserForUserId( projectOffering. );
                //projectOffering.Supervisor = new User( )
                //{
                //   UserId = supervisorModel.UserId,
                //   Username = supervisorModel.Username
                //};

                ProjectOfferings.Add(projectOffering);
            }

            Enrollments = new List <Enrollment>( );
            foreach (var e in enrollments)
            {
                var enrollment = new Enrollment( )
                {
                    EnrollmentId   = e.EnrollmentId,
                    UnitOfferingId = e.UnitOfferingId,
                    UserId         = e.UserId,
                    UnitOffering   = this
                };

                var userData = UserProcessor.SelectUserForUserId(e.UserId);
                var user     = new User( )
                {
                    UserId    = userData.UserId,
                    Username  = userData.Username,
                    FirstName = userData.FirstName,
                    LastName  = userData.LastName,
                };
                enrollment.Student = user;

                Enrollments.Add(enrollment);
            }
        }