Exemple #1
0
        public virtual ActionResult Create(int?sessionIdentity)
        {
            var session           = sessionIdentity.HasValue ? _sessionRepository.GetById(sessionIdentity.Value) : null;
            var classPeriodModels = GetClassPeriodNameModels();
            var classRoomModels   = GetClassRoomModels();

            var createModel = CreateModel.CreateNewWith(classPeriodModels, classRoomModels, session);

            return(View(createModel));
        }
Exemple #2
0
        public virtual ActionResult Create(CreateModel createModel)
        {
            if (!ModelState.IsValid)
            {
                createModel.Periods    = GetClassPeriodNameModels();
                createModel.Classrooms = GetClassRoomModels();

                return(View(createModel));
            }

            CreateSection(createModel);

            return(RedirectToAction(Actions.Index()));
        }
Exemple #3
0
        public static CreateModel CreateNewWith(List<ClassPeriodListItemModel> classPeriods, List<LocationListItemModel> classRoomModels, Data.Entities.Session session)
        {
            var createModel = new CreateModel
            {
                Periods = classPeriods,
                Classrooms = classRoomModels,
            };

            if (session != null)
            {
                createModel.SessionId = session.SessionIdentity;
                createModel.Session = session.SessionName;
            }

            return createModel;
        }
Exemple #4
0
        public static CreateModel CreateNewWith(List <ClassPeriodListItemModel> classPeriods, List <LocationListItemModel> classRoomModels, Data.Entities.Session session)
        {
            var createModel = new CreateModel
            {
                Periods    = classPeriods,
                Classrooms = classRoomModels,
            };

            if (session != null)
            {
                createModel.SessionId = session.SessionIdentity;
                createModel.Session   = session.SessionName;
            }

            return(createModel);
        }
Exemple #5
0
        private void CreateSection(CreateModel createModel)
        {
            var section = _createModelToSectionMapper.Build(createModel);
            var session = _genericRepository.Get <Session>(s => s.SessionIdentity == createModel.SessionId);

            var courseOfferingByPrimaryKeysQuery = new CourseOfferingByPrimaryKeysQuery(createModel.Course,
                                                                                        session.SchoolYear, session.TermTypeId);

            if (CourseOfferingNeedsToBeCreated(courseOfferingByPrimaryKeysQuery))
            {
                var courseOffering = _createModelToCourseOfferingMapper.Build(createModel);
                _genericRepository.Add(courseOffering);
            }

            _genericRepository.Add(section);
            _genericRepository.Save();
        }
        private void Setup()
        {
            _genericRepository = Substitute.For<IGenericRepository>();
            _sectionCreateModel = new CreateSectionModelBuilder().Build();
            _validator = new CreateModelValidator(_genericRepository);

            _genericRepository.Get(Arg.Any<Expression<Func<Web.Data.Entities.Session, bool>>>())
                .Returns(new SessionBuilder().Build());

            _genericRepository.Get(Arg.Any<Expression<Func<Web.Data.Entities.ClassPeriod, bool>>>())
                .Returns(new ClassPeriodBuilder().Build());

            _genericRepository.Get(Arg.Any<Expression<Func<Web.Data.Entities.Location, bool>>>())
                .Returns(new LocationBuilder().Build());

            _genericRepository.Get(Arg.Any<Expression<Func<Web.Data.Entities.Course, bool>>>())
                .Returns(new CourseBuilder().Build());
        }
 public void HaveEnteredValidInputForAllFields()
 {
     _createSectionModel = new CreateSectionModelBuilder().Build();
     _sectionIndexPage = _sectionCreatePage.CreateSection(_createSectionModel);
 }
        public virtual ActionResult Create(CreateModel createModel)
        {
            if (!ModelState.IsValid)
            {
                createModel.Periods = GetClassPeriodNameModels();
                createModel.Classrooms = GetClassRoomModels();

                return View(createModel);
            }

            CreateSection(createModel);

            return RedirectToAction(Actions.Index());
        }
        private void CreateSection(CreateModel createModel)
        {
            var section = _createModelToSectionMapper.Build(createModel);
            var session = _genericRepository.Get<Session>(s => s.SessionIdentity == createModel.SessionId);

            var courseOfferingByPrimaryKeysQuery = new CourseOfferingByPrimaryKeysQuery(createModel.Course,
                session.SchoolYear, session.TermTypeId);

            if (CourseOfferingNeedsToBeCreated(courseOfferingByPrimaryKeysQuery))
            {
                var courseOffering = _createModelToCourseOfferingMapper.Build(createModel);
                _genericRepository.Add(courseOffering);
            }

            _genericRepository.Add(section);
            _genericRepository.Save();
        }