コード例 #1
0
        public virtual ActionResult Create(CreateModel createModel)
        {
            if (!ModelState.IsValid)
                return View(createModel);

            var classPeriod = new ClassPeriod();
            _createModelToClassPeriodMapper.Map(createModel, classPeriod);

            _genericRepository.Add(classPeriod);
            _genericRepository.Save();

            return RedirectToAction(MVC.ClassPeriod.Index());
        }
コード例 #2
0
ファイル: MapperTests.cs プロジェクト: InnovateEDUNYC/NGLV1
        public void ShouldMapCreateModelToClassPeriod()
        {
            SetUp();
            var classPeriodEntity = new Web.Data.Entities.ClassPeriod();
            var classPeriodCreateModel = new CreateModel
            {
                ClassPeriodName = "Period 1"
            };

            var createModeltoClassPeriodMapper = new CreateModelToClassPeriodMapper(_schoolRepository);
            createModeltoClassPeriodMapper.Map(classPeriodCreateModel, classPeriodEntity);

            classPeriodEntity.ClassPeriodName.ShouldBe("Period 1");
            classPeriodEntity.SchoolId.ShouldBe(1);
        }
コード例 #3
0
 private void Setup()
 {
     _genericRepository = Substitute.For<IGenericRepository>();
     _classPeriodCreateModel = new CreateClassPeriodModelBuilder().Build();
     _validator = new CreateModelValidator(new RepositoryReader<Web.Data.Entities.ClassPeriod>(_genericRepository));   
 }
コード例 #4
0
 public void HaveEnteredValidInputForAllFields()
 {
     _classPeriodCreateModel = new CreateClassPeriodModelBuilder().WithName("Period X").Build();
     _classPeriodIndexPage = _classPeriodCreatePage.CreateClassPeriod(_classPeriodCreateModel);
 }