Example #1
0
 public void Validate()
 {
     if (!ValidateFields.ValidateRequerid(CategoryName))
     {
         throw new ValidationException("Field CategoryName is requerid.");
     }
 }
 private void validateModelState(ActionExecutingContext context)
 {
     if (!context.ModelState.IsValid)
     {
         var validateFields = new ValidateFields(context.ModelState.SelectMany(sm => sm.Value.Errors).Select(s => s.ErrorMessage));
         context.Result = new BadRequestObjectResult(validateFields);
     }
 }
Example #3
0
        public void Test_Validate_Then_With_Exception()
        {
            var pipeline = Pipe.Init(() => new Result(), new Validator <HttpRequestContext, Result>())
                           .Then((HttpRequestContext a) => ValidateFields.ValidationThatThrowsAnException());

            var pipelineResult = (Validator <HttpRequestContext, Result>)pipeline(new HttpRequestContext());

            Assert.IsTrue(pipelineResult.GetOptionType == OptionType.Exception);
            Assert.IsTrue(pipelineResult.ExceptionVal.Message == ValidateFields.ExceptionMessage);
        }
Example #4
0
        public void Test_Validate_Then_WithInvalid()
        {
            var pipeline = Pipe.Init(() => new Result(), new Validator <HttpRequestContext, Result>())
                           .Then(resp => ValidateFields.AddInvalidAge(resp));

            var pipelineResult = (Validator <HttpRequestContext, Result>)pipeline(new HttpRequestContext());

            Assert.IsTrue(pipelineResult.GetOptionType == OptionType.Validation);
            Assert.IsTrue(pipelineResult.SupplementVal.IsValid == false);
            Assert.IsTrue(pipelineResult.SupplementVal.Messages.Count == 1);
        }
Example #5
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                patient.LastName  = frmPatientRecordTabs.lastName = frmPatientRecordTabs.txtLastName.Text;
                patient.FirstName = frmPatientRecordTabs.firstName = frmPatientRecordTabs.txtFirstName.Text;
                patient.Dob       = frmPatientRecordTabs.dob = (DateTime)frmPatientRecordTabs.dtpDOB.Value;
                patient.Address   = frmPatientRecordTabs.streetAddress = frmPatientRecordTabs.txtAddress.Text;
                patient.City      = frmPatientRecordTabs.city = frmPatientRecordTabs.txtCity.Text;
                patient.State     = frmPatientRecordTabs.state = frmPatientRecordTabs.cbState.Text;
                patient.Zip       = frmPatientRecordTabs.zip = frmPatientRecordTabs.txtZipcode.Text;
                patient.Phone     = frmPatientRecordTabs.phone = frmPatientRecordTabs.txtPhone.Text;
                patient.Gender    = frmPatientRecordTabs.gender = frmPatientRecordTabs.cbGender.Text;
                patient.Ssn       = frmPatientRecordTabs.ssn = frmPatientRecordTabs.txtSSN.Text;

                if (ValidateFields.patientFields(frmPatientRecordTabs))
                {
                    bool isUpdate = false;


                    isUpdate = eClinicalsController.UpdatePatient(patient.ContactID, patient.LastName,
                                                                  patient.FirstName, patient.Dob, patient.Address, patient.City, patient.State,
                                                                  patient.Zip, patient.Phone, patient.Gender, patient.Ssn);

                    //refresh later
                    mainForm.patientInfoRibbonController.AddUserInfoTopInfo(patient.FirstName, patient.LastName);
                    string age = (patient.Dob.Year - DateTime.Now.Year).ToString();
                    mainForm.patientInfoRibbonController.AddUserInfo(age, patient.Gender, patient.PatientID.ToString());
                    mainForm.patientInfoRibbonController.AddAppointmentInfo("", "Headache \n Cough");


                    if (isUpdate)
                    {
                        DisableEdit();
                    }
                }
            }
            catch (Exception ex)
            {
                this.mainForm.Status(ex.Message, Color.Red);
            }
            mainForm.patientInfoRibbonController.AddContactInfoFull(patient.Phone, patient.Address, patient.City, patient.State, patient.Zip);
            mainForm.patientInfoRibbonController.AddUserInfo(mainForm.patientInfoRibbonController.getAge(patient.Dob).ToString(), patient.Gender, patient.PatientID.ToString());

            mainForm.patientInfoRibbonController.AddUserInfoTopInfo(patient.FirstName, patient.LastName);
        }
 public CustomValidateField(ValidateFields type)
 {
     typeField = type;
 }