public IEnumerable <ValidationResult> Validate(string instanceName, bool isRequired = false) { var result = new List <ValidationResult>(); if (string.IsNullOrWhiteSpace(Reason)) { result.Add(new ValidationResult(string.Empty, new[] { $"{instanceName}.{nameof(Reason)}" })); } if (DeceaseCase) { result.AddRange(Year.Validate($"{instanceName}.{nameof(Year)}", true)); } else { for (var i = 0; i <= Periods.Count - 1; i++) { result.AddRange(Periods[i].Validate($"{instanceName}.{nameof(Periods)}[{i}]")); } } result.AddRange(PhysicianInfos.Validate($"{instanceName}.{nameof(PhysicianInfos)}")); return(result); }
public XmlElement ToXmlElement(XmlHelper helper) { var xmlElement = helper.CreateElement(nameof(MedicalConsultationModel).Replace("Model", string.Empty)); xmlElement.AppendChild(helper.CreateElement(nameof(Reason), Reason)); xmlElement.AppendChild(helper.CreateElement(nameof(Periods), Periods.Select(x => x.ToXmlElement(helper)).ToList())); xmlElement.AppendChild(helper.CreateElement(nameof(PhysicianInfos), PhysicianInfos.ToXmlElement(helper))); return(xmlElement); }
public XmlElement ToXmlElement(XmlHelper helper) { var xmlElement = helper.CreateElement(nameof(AboutIllnessModel).Replace("Model", string.Empty)); xmlElement.AppendChild(helper.CreateElement(nameof(FirstOnsetDate), helper.TransformerDate(FirstOnsetDate))); xmlElement.AppendChild(helper.CreateElement(nameof(OnsetDescription), OnsetDescription)); xmlElement.AppendChild(helper.CreateElement(nameof(LastMedicalConsultationDate), helper.TransformerDate(LastMedicalConsultationDate))); xmlElement.AppendChild(helper.CreateElement(nameof(PhysicianInfos), PhysicianInfos.Select(x => x.ToXmlElement(helper)).ToList())); xmlElement.AppendChild(helper.CreateElement(nameof(Diagnosis), Diagnosis)); xmlElement.AppendChild(helper.CreateElement(nameof(HasFamilyMemberWithSameProblem), (HasFamilyMemberWithSameProblem == "O").ToString())); if (HasFamilyMemberWithSameProblem == "O") { xmlElement.AppendChild(helper.CreateElement(nameof(FamilyMembers), FamilyMembers.ToXmlElement(helper))); } return(xmlElement); }