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()); }
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); }
private void Setup() { _genericRepository = Substitute.For<IGenericRepository>(); _classPeriodCreateModel = new CreateClassPeriodModelBuilder().Build(); _validator = new CreateModelValidator(new RepositoryReader<Web.Data.Entities.ClassPeriod>(_genericRepository)); }
public void HaveEnteredValidInputForAllFields() { _classPeriodCreateModel = new CreateClassPeriodModelBuilder().WithName("Period X").Build(); _classPeriodIndexPage = _classPeriodCreatePage.CreateClassPeriod(_classPeriodCreateModel); }