public void should_enter_student() { var helper = ServiceLocator.Current.GetInstance<IStudentMappingHelper>(); var studentRepo = ServiceLocator.Current.GetInstance<IStudentRepository>(); var studentDto = studentRepo.Find(s => s.LastName == "Cobb"); if (studentDto != null) studentRepo.Delete(studentDto); var student = new StudentPrototype() { FirstName = "Bob", LastName = "Cobb", SchoolName = "Transylvania High" , SchoolId = 1, CreateNewSchool = false, AmountFromEnvelope = "23.33", AmountFromWebsite = "0", FundraisingGoal = "0", Teacher = 25, MinutesRead = "33", PagesRead = "44", ReadingGoal = "100", EnvelopeNumber = "343" }; helper.LoadPrototype(student); _sut.ValidateAndInsert(student, helper); studentDto.ShouldNotBeNull(); studentDto.TeacherId.ShouldEqual(0); studentDto.SchoolName.ShouldBeNull(); }
public ActionResult create(StudentPrototype request) { try { return _svc.ValidateAndInsert(request, _helper) ? View("NextStudent", new Schools()) : View("CreateStudent", request); } catch (Exception ex) { request.ValidationErrorMsgs = "An error occurred: " + ex; return View("CreateStudent", request); } }
public ActionResult CreateStudent(StudentPrototype student) { _helper.LoadPrototype(student); return create(student); }
public void LoadPrototype(StudentPrototype prototype) { School = _schoolRepo.Find(s => s.Id == prototype.SchoolId); prototype.SchoolName = School.Name; Teacher = getContactDto(prototype); }
private ContactDto getContactDto(StudentPrototype request) { var schoolDto = _schoolRepo.Find(s => s.Id == request.SchoolId); var teacher = schoolDto.Contacts.Find(c => c.Id == request.Teacher); return teacher; }