Exemple #1
0
 public static T Get <T>(Func <PersistenceClassesDataContext, T> dataContextAction)
 {
     using (PersistenceClassesDataContext dataContext = new PersistenceClassesDataContext(GetDatabaseConnectionString()))
     {
         return(dataContextAction(dataContext));
     }
 }
Exemple #2
0
 public static void Execute(Action <PersistenceClassesDataContext> dataContextAction)
 {
     using (PersistenceClassesDataContext dataContext = new PersistenceClassesDataContext(GetDatabaseConnectionString()))
     {
         dataContextAction(dataContext);
     }
 }
Exemple #3
0
        private static void UpdateExistingHospitalFields(Guid id, HospitalDto hospitalDto,
                                                         PersistenceClassesDataContext dataContext)
        {
            var hospital = dataContext.Hospitals.FirstOrDefault(p => p.Guid.Equals(id));

            if (hospital == null)
            {
                throw GetResponseException(HttpStatusCode.NotFound, Messages.HospitalDoesNotExist);
            }
            if (hospitalDto.Name != null)
            {
                hospital.Name = hospitalDto.Name;
            }
            if (hospitalDto.Owner != null)
            {
                hospital.Owner = hospitalDto.Owner;
            }
            if (hospitalDto.MobilePhone != null)
            {
                hospital.MobilePhone = hospitalDto.MobilePhone;
            }
            if (hospitalDto.Address != null)
            {
                hospital.Address = hospitalDto.Address;
            }
            dataContext.SubmitChanges();
        }
Exemple #4
0
        private static void UpdateExistingDoctorFields(Guid id, DoctorDto doctorDto, PersistenceClassesDataContext dataContext)
        {
            var doctor = dataContext.Doctors.FirstOrDefault(p => p.Guid.Equals(id));

            if (doctor == null)
            {
                throw GetResponseException(HttpStatusCode.NotFound, Messages.DoctorDoesNotExist);
            }
            if (doctorDto.Name != null)
            {
                doctor.Name = doctorDto.Name;
            }
            if (doctorDto.MiddleName != null)
            {
                doctor.MiddleName = doctorDto.MiddleName;
            }
            if (doctorDto.FamilyName != null)
            {
                doctor.FamilyName = doctorDto.FamilyName;
            }
            if (doctorDto.Address != null)
            {
                doctor.Address = doctorDto.Address;
            }
            if (doctorDto.MobilePhone != null)
            {
                doctor.MobilePhone = doctorDto.MobilePhone;
            }
            if (doctorDto.Egn != null)
            {
                doctor.Egn = doctorDto.Egn;
            }
            dataContext.SubmitChanges();
        }
Exemple #5
0
        private static void DeleteExistingReservation(Guid id, PersistenceClassesDataContext dataContext)
        {
            var reservation = dataContext.HistoricalReservations.FirstOrDefault(r => r.Guid.Equals(id));

            dataContext.HistoricalReservations.DeleteOnSubmit(
                reservation ?? throw GetResponseException(HttpStatusCode.NotFound, Messages.ReservationDoesNotExist));
            dataContext.SubmitChanges();
        }
Exemple #6
0
        private static void DeleteExistingVisit(Guid id, PersistenceClassesDataContext dataContext)
        {
            var visit = dataContext.HistoricalVisits.FirstOrDefault(v => v.Guid.Equals(id));

            dataContext.HistoricalVisits.DeleteOnSubmit(
                visit ?? throw GetResponseException(HttpStatusCode.NotFound, Messages.VisitDoesNotExist));
            dataContext.SubmitChanges();
        }
Exemple #7
0
        private static void DeleteExistingPatient(Guid id, PersistenceClassesDataContext dataContext)
        {
            var patient = dataContext.Patients.FirstOrDefault(p => p.Guid.Equals(id));

            dataContext.Patients.DeleteOnSubmit(
                patient ?? throw GetResponseException(HttpStatusCode.NotFound, Messages.PatientDoesNotExist));
            dataContext.SysUsers.DeleteOnSubmit(patient.SysUser);
            dataContext.SubmitChanges();
        }
Exemple #8
0
        private static void DeleteExistingHospital(Guid id, PersistenceClassesDataContext dataContext)
        {
            var hospital = dataContext.Hospitals.FirstOrDefault(databaseHospital => databaseHospital.Guid.Equals(id));

            if (hospital == null)
            {
                throw GetResponseException(HttpStatusCode.NotFound, Messages.HospitalDoesNotExist);
            }
            dataContext.SysUsers.DeleteOnSubmit(hospital.SysUser);
            dataContext.Hospitals.DeleteOnSubmit(hospital);
            dataContext.SubmitChanges();
        }
Exemple #9
0
        private static void DeleteExistingDoctor(Guid id, PersistenceClassesDataContext dataContext)
        {
            var doctor = dataContext.Doctors.FirstOrDefault(databaseDoctor => databaseDoctor.Guid.Equals(id));

            if (doctor == null)
            {
                throw GetResponseException(HttpStatusCode.NotFound, Messages.DoctorDoesNotExist);
            }
            dataContext.SysUsers.DeleteOnSubmit(doctor.SysUser);
            dataContext.Doctors.DeleteOnSubmit(doctor);
            dataContext.SubmitChanges();
        }
Exemple #10
0
        private static void UpdateExistingVisitFields(Guid id, HistoricalVisitDto historicalVisitDto,
                                                      PersistenceClassesDataContext dataContext)
        {
            var visit = dataContext.HistoricalVisits.FirstOrDefault(r => r.Guid.Equals(id));

            if (visit == null)
            {
                throw GetResponseException(HttpStatusCode.NotFound, Messages.VisitDoesNotExist);
            }
            if (historicalVisitDto.VisitTime != DateTime.MinValue)
            {
                visit.VisitTime = historicalVisitDto.VisitTime;
            }
            dataContext.SubmitChanges();
        }
Exemple #11
0
        private static void UpdateExistingReservationFields(Guid id, HistoricalReservationDto historicalReservationDto,
                                                            PersistenceClassesDataContext dataContext)
        {
            var reservation = dataContext.HistoricalReservations.FirstOrDefault(r => r.Guid.Equals(id));

            if (reservation == null)
            {
                throw GetResponseException(HttpStatusCode.NotFound, Messages.ReservationDoesNotExist);
            }
            if (historicalReservationDto.ReservationTime != DateTime.MinValue) // Is assigned? (Non nullable)
            {
                reservation.ReservationTime = historicalReservationDto.ReservationTime;
            }
            if (historicalReservationDto.Reason != null)
            {
                reservation.Reason = historicalReservationDto.Reason;
            }
            dataContext.SubmitChanges();
        }
Exemple #12
0
        private static void UpdateExistingDiagnosisFields(Guid id, HistoricalDiagnosisDto historicalDiagnosisDto,
                                                          PersistenceClassesDataContext dataContext)
        {
            var diagnosis = dataContext.HistoricalDiagnosis.FirstOrDefault(r => r.Guid.Equals(id));

            if (diagnosis == null)
            {
                throw GetResponseException(HttpStatusCode.NotFound, Messages.DiagnosisDoesNotExist);
            }
            if (historicalDiagnosisDto.DiagnosisDescription != null)
            {
                diagnosis.SicknessDescription = historicalDiagnosisDto.DiagnosisDescription;
            }
            if (historicalDiagnosisDto.DiagnosisTime != DateTime.MinValue)
            {
                diagnosis.DiagnosisTime = historicalDiagnosisDto.DiagnosisTime;
            }
            dataContext.SubmitChanges();
        }
Exemple #13
0
        private static void UpdateExistingPatientFields(Guid id, PatientDto patientDto, PersistenceClassesDataContext dataContext)
        {
            var patient = dataContext.Patients.FirstOrDefault(p => p.Guid.Equals(id));

            if (patient == null)
            {
                throw GetResponseException(HttpStatusCode.NotFound, Messages.PatientDoesNotExist);
            }
            if (patientDto.Name != null)
            {
                patient.Name = patientDto.Name;
            }
            if (patientDto.MiddleName != null)
            {
                patient.MiddleName = patientDto.MiddleName;
            }
            if (patientDto.FamilyName != null)
            {
                patient.FamilyName = patientDto.FamilyName;
            }
            if (patientDto.Address != null)
            {
                patient.Address = patientDto.Address;
            }
            if (patientDto.Age != 0)
            {
                patient.Age = patientDto.Age;
            }
            if (patientDto.MobilePhone != null)
            {
                patient.MobilePhone = patientDto.MobilePhone;
            }
            if (patientDto.Egn != null)
            {
                patient.Egn = patientDto.Egn;
            }
            dataContext.SubmitChanges();
        }