public TeachingPeriod GetTeachingPeriodForName(string name)
        {
            var data           = TeachingPeriodProcessor.SelectTeachingPeriodForName(name);
            var teachingPeriod = new TeachingPeriod
            {
                TeachingPeriodId = data.TeachingPeriodId,
                Name             = data.Name,
                Month            = data.Month,
                Day = data.Day
            };

            TeachingPeriod = teachingPeriod;
            return(TeachingPeriod);
        }
        public List <TeachingPeriod> GetTeachingPeriods( )
        {
            var teachingPeriodData = TeachingPeriodProcessor.SelectTeachingPeriods( );

            TeachingPeriods = new List <TeachingPeriod>( );
            foreach (var row in teachingPeriodData)
            {
                var teachingPeriod = new TeachingPeriod( )
                {
                    TeachingPeriodId = row.TeachingPeriodId,
                    Name             = row.Name
                };

                TeachingPeriods.Add(teachingPeriod);
            }
            return(TeachingPeriods);
        }
        //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);
            }
        }