예제 #1
0
        public StudentModule(IStudentProcessingService svc)
            : base("student")
        {
            Post["/update"] = parm =>
                                    {
            //
                                          var requestPrototype = this.Bind<StudentPrototype>();
                                         try
                                         {
                                             return svc.ValidateAndUpdate(requestPrototype) ? View["NextStudent", new Schools()] : View["EditStudentRetry", requestPrototype];
                                         }
                                         catch(Exception ex)
                                         {
                                             requestPrototype.ValidationErrorMsgs  = "An error occurred: " + ex;
                                             return View["EditStudentRetry", requestPrototype];
                                         }
            //
                                    };
            Post["/create"] = parm =>
                                     {
                                         var request = this.Bind<StudentPrototype>();
                                         try
                                         {
                                             return svc.ValidateAndInsert(request) ? View["NextStudent", new Schools()] : View["CreateStudentRetry", request];
                                         }
                                         catch(Exception ex)
                                         {
                                             request.ValidationErrorMsgs = "An error occurred: " + ex;
                                             return View["CreateStudentRetry", request];
                                         }

                                     };
        }
 public StudentController(IStudentProcessingService svc, 
     IStudentRepository studentRepo, IStudentMappingHelper helper, ISchoolRepository schoolRepo)
 {
     _svc = svc;
     _studentRepo = studentRepo;
     _helper = helper;
     _schoolRepo = schoolRepo;
 }
 public void SetUpForAllTests()
 {
     _sut = ServiceLocator.Current.GetInstance<IStudentProcessingService>();
 }