Ejemplo n.º 1
0
        public void SaveHSHI(HighSchoolHealthInfoClass hshi, HealthInfoTextValidation hiCheck)
        {
            string        query      = $"Update HighSchoolHealthInfo Set ";
            List <string> listToSave = new List <string>(new string[] { "primaryPhysician = @PrimaryPhysician", "otherPhysician = @OtherPhysician", "pPhysicianPhoneNum = @PphysicianPhoneNum", "oPhysicianPhoneNum = @OphysicianPhoneNum", "diabeticType = @DiabeticType", "allergies = @Allergies", "heartIssues = @HeartIssues", "metabolic = @Metabolic", "jointMuscle = @JointMuscle", "chronicIllness = @ChronicIllness", "migraines = @Migraines", "neurological = @Neurological", "pulmonary = @Pulmonary", "asthma = @Asthma", "other = @Other", "otherMeds = @OtherMeds", "specificFirstAidNeeds = @SpecificFirstAidNeeds", "repPermissionForTreatment = @RepPermissionForTreatment", "healthSignature = @signature" });
            List <string> toRemove   = hiCheck.IsValid;

            foreach (var v in toRemove)
            {
                for (int i = 0; i < listToSave.Count; i++)
                {
                    if (listToSave[i].Contains(v))
                    {
                        listToSave.RemoveAt(i);
                        i--;
                    }
                }
            }

            foreach (var s in listToSave)
            {
                if (listToSave.IndexOf(s) != listToSave.Count - 1)
                {
                    query += s + ",";
                }

                else
                {
                    query += s;
                }
            }

            query += " Where Id = @id";

            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("EnrollmentDB")))
            {
                connection.Execute(query,
                                   new { signature = hshi.healthSignature, PrimaryPhysician = hshi.primaryPhysician, OtherPhysician = hshi.otherPhysician, PphysicianPhoneNum = hshi.pPhysicianPhoneNum, OphysicianPhoneNum = hshi.oPhysicianPhoneNum, DiabeticType = hshi.diabeticType, Allergies = hshi.allergies, HeartIssues = hshi.heartIssues, Metabolic = hshi.metabolic, JointMuscle = hshi.jointMuscle, ChronicIllness = hshi.chronicIllness, Migraines = hshi.migraines, Neurological = hshi.neurological, Pulmonary = hshi.pulmonary, Asthma = hshi.asthma, Other = hshi.other, OtherMeds = hshi.otherMeds, SpecificFirstAidNeeds = hshi.specificFirstAidNeeds, RepPermissionForTreatment = hshi.repPermissionForTreatment, id = hshi.Id });
            }
        }