Esempio n. 1
0
        public static List <VaccinationForPatientsTab> GetRepresentation(int treatmentHistoryId)
        {
            using (var context = new DataBaseContext())
            {
                var TreatmentHistory = context.TreatmentHistories
                                       .Include(x => x.PastVaccinations)
                                       .Include(x => x.RequiredVaccinations)
                                       .SingleOrDefault(x => x.Id == treatmentHistoryId);

                return(TreatmentHistory.PastVaccinations
                       .Select(x => new VaccinationForPatientsTab()
                {
                    Id = x.Id,
                    Status = x.VaccineStatus,
                    StatusText = CustomEnumToString.GetVaccineStatusText(x.VaccineStatus),
                    Name = x.VaccinesName,
                    VaccinationDoneDate = x.VaccinationDate.HasValue ? x.VaccinationDate.Value.ToShortDateString() : "-",
                    VaccinationObligatoryByDate = x.ObligatoryBy.HasValue ? x.ObligatoryBy.Value.ToShortDateString() : "Nie wymagane"
                })
                       .ToList()
                       .Concat(TreatmentHistory.RequiredVaccinations
                               .Select(x => new VaccinationForPatientsTab()
                {
                    Id = x.Id,
                    Status = x.VaccineStatus,
                    StatusText = CustomEnumToString.GetVaccineStatusText(x.VaccineStatus),
                    Name = x.VaccinesName,
                    VaccinationDoneDate = x.VaccinationDate.HasValue ? x.VaccinationDate.Value.ToShortDateString() : "-",
                    VaccinationObligatoryByDate = x.ObligatoryBy.HasValue ? x.ObligatoryBy.Value.ToShortDateString() : "Nie wymagane"
                })
                               .ToList())
                       .ToList());
            }
        }