Пример #1
0
		public void Registrar_RequestTutionAmount_Valid_StudentNumber()
		{
			Registrar registrar = new Registrar();
			TuitionAmountRequest request = new TuitionAmountRequest() { StudentNumber = "88634352" };
			BSTSmartScholarshipSerializer<TuitionAmountRequest> serializer = new BSTSmartScholarshipSerializer<TuitionAmountRequest>();
			XmlDocument requestDoc = serializer.Serialize(request);
			ISchemaProvider provider = new XmlSchemaProvider();
			requestDoc.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.TuitionAmountRequest.xsd"));
			requestDoc.Validate(null);

			XmlDocument responseDoc = registrar.RequestTuitionAmount(requestDoc);
			responseDoc.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.TuitionAmountResponse.xsd"));
			responseDoc.Validate(null);

			BSTSmartScholarshipSerializer<TuitionAmountResponse> deserilaizer = new BSTSmartScholarshipSerializer<TuitionAmountResponse>();
			TuitionAmountResponse response = deserilaizer.Deserialize(responseDoc);

			Assert.AreEqual(response.StudentNumber, request.StudentNumber);
			Assert.AreEqual(response.TuitionAmount, 5500.00);
		}
		public void Serialize_TuitionAmountRequest_ValidateSchema_Invalid_StudentNumber()
		{
			TuitionAmountRequest request = new TuitionAmountRequest() { StudentNumber = "88634351" };
			request.StudentNumber = "F";

			XmlDocument actual = (new BSTSmartScholarshipSerializer<TuitionAmountRequest>()).Serialize(request);
			XmlSchemaProvider provider = new XmlSchemaProvider();

			actual.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.TuitionAmountRequest.xsd"));
			actual.Validate(null);
		}
Пример #3
0
		public ActionResult AwardApplicant(String sn)
		{
			List<Applicant> applicants = new List<Applicant>(ApplicantList.GetList(a => a.IsVerified.GetValueOrDefault(false) && a.IsEligible.GetValueOrDefault(false)));
			IEmailService emailService = new EmailService();
			EmailUtility email = new EmailUtility(emailService);

			Applicant applicant = applicants.FirstOrDefault(a => a.StudentNumber.Equals(sn, StringComparison.OrdinalIgnoreCase));

			//Notify other applicants that they did not win.
			foreach (String studentNumber in applicants.Where(a=> !a.StudentNumber.Equals(sn, StringComparison.OrdinalIgnoreCase)).Select(a => a.StudentNumber))
			{	
				email.SendNotAwardedEmail(studentNumber);
			}

			///Prepare the request for the registrar.
			TuitionAmountRequest request = new TuitionAmountRequest(applicant.StudentNumber);
			XmlSchemaProvider provider = new XmlSchemaProvider();
			XmlDocument requestDocument = (new BSTSmartScholarshipSerializer<TuitionAmountRequest>()).Serialize(request);
			Registrar registrar = new Registrar();

			XmlDocument responseDocument = registrar.RequestTuitionAmount(requestDocument);
			TuitionAmountResponse response = (new BSTSmartScholarshipSerializer<TuitionAmountResponse>()).Deserialize(responseDocument);

			//Award the scholarship
			Award.AddAward(applicant.StudentNumber, applicant.FirstName, applicant.LastName, response.TuitionAmount);

			//Notify Accounting of the reimbursement amount.
			Award.NotifyAccounting(response.StudentNumber, response.TuitionAmount);

			//Send award emails.
			email.SendAwardedEmail(sn, response.TuitionAmount);

			return RedirectToAction("Awarded", "Admin");
		}