Esempio n. 1
0
        public void InsertInjuriesDiseases(int id, InjuriesDiseases injuriesDiseases)
        {
            var entity = context.Patients.FirstOrDefault(t => t.Id == id);

            if (entity == null)
            {
                throw new NullReferenceException();
            }

            injuriesDiseases.Id = 0;
            entity.InjuriesDiseases.Add(injuriesDiseases);

            context.SaveChanges();
        }
        public static InjuriesDiseasesView EntityToView(this InjuriesDiseases entity)
        {
            if (entity != null)
            {
                return(new InjuriesDiseasesView
                {
                    Id = entity.Id,
                    DateInjuriesOrDiseases = entity.DateInjuriesOrDiseases,
                    ReleasedInMainGroup = entity.ReleasedInMainGroup,
                    DisabilityCountDay = entity.DisabilityCountDay,
                    Diagnosis = entity.Diagnosis,
                    DrugTherapy = entity.DrugTherapy,
                    PhysiotherapyTreatment = entity.PhysiotherapyTreatment,
                    Other = entity.Other,
                    DisabilityType = (Enums.DisabilityType)entity.DisabilityTypeId,
                    PatientId = entity.PatientId,
                    MRIs = entity.MRIs.EntityToView() ?? new List <MRIView>(),
                    CommonUltrasounds = entity.CommonUltrasounds.EntityToView() ?? new List <CommonUltrasoundView>(),
                    Radiographies = entity.Radiographies.EntityToView() ?? new List <RadiographyView>()
                });
            }

            return(null);
        }