Example #1
0
 public Message Select(int id)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.Messages.Include("Doctor").Include("Patient").FirstOrDefault(d => d.Id == id));
     }
 }
Example #2
0
        public Extensions.DataBaseResult Update(Diagnosis newInfoDiagnosis)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Diagnoses.Any(d => d.Name == newInfoDiagnosis.Name && d.Id != newInfoDiagnosis.Id))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }

                Diagnosis diagnosis = ctx.Diagnoses.FirstOrDefault(d => d.Id == newInfoDiagnosis.Id);
                if (diagnosis == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                diagnosis.Name     = newInfoDiagnosis.Name;
                diagnosis.IsActive = newInfoDiagnosis.IsActive;

                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
 public DoctorPhone Select(int id)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.DoctorPhones.Include("Doctor").FirstOrDefault(d => d.Id == id));
     }
 }
 public LaboratoryItemUnit Select(int id)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.LaboratoryItemUnits.FirstOrDefault(d => d.Id == id));
     }
 }
Example #5
0
 public Diagnosis Select(int id)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.Diagnoses.Include("Department").FirstOrDefault(d => d.Id == id));
     }
 }
Example #6
0
 public List <Holiday> Holidays()
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.Holidays.ToList());
     }
 }
Example #7
0
 public BloodGroup Select(int id)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.BloodGroups.Include("Patient").FirstOrDefault(d => d.Id == id));
     }
 }
 public Patient Select(string tc)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.Patients.FirstOrDefault(p => p.TcNo == tc));
     }
 }
        public Extensions.DataBaseResult Update(Patient newInfoPatient)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Patient patient = ctx.Patients.FirstOrDefault(d => d.Id == newInfoPatient.Id);
                if (patient == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                patient.TcNo         = newInfoPatient.TcNo;
                patient.Name         = newInfoPatient.Name;
                patient.Surname      = newInfoPatient.Surname;
                patient.MotherName   = newInfoPatient.MotherName;
                patient.FatherName   = newInfoPatient.FatherName;
                patient.Address      = newInfoPatient.Address;
                patient.CityId       = newInfoPatient.CityId;
                patient.CountryId    = newInfoPatient.CountryId;
                patient.Phone        = newInfoPatient.Phone;
                patient.Mail         = newInfoPatient.Mail;
                patient.BirthDay     = newInfoPatient.BirthDay;
                patient.Gender       = newInfoPatient.Gender;
                patient.BloodGroupId = newInfoPatient.BloodGroupId;
                patient.IsActive     = newInfoPatient.IsActive;
                patient.Password     = newInfoPatient.Password;
                bool b = ctx.SaveChanges() > -1;
                return(b ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
        public Extensions.DataBaseResult Update(Department newInfoDepartment)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Departments.Any(d => d.Name == newInfoDepartment.Name && d.Id != newInfoDepartment.Id))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }

                Department department = ctx.Departments.FirstOrDefault(d => d.Id == newInfoDepartment.Id);
                if (department == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                department.Name     = newInfoDepartment.Name;
                department.IsActive = newInfoDepartment.IsActive;
                department.MinAge   = newInfoDepartment.MinAge;
                department.MaxAge   = newInfoDepartment.MaxAge;
                department.Gender   = newInfoDepartment.Gender;

                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
        public Extensions.DataBaseResult Delete(int id)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Patient patient = ctx.Patients.FirstOrDefault(d => d.Id == id);
                if (patient == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                bool b = ctx.Consultations.Any(d => d.PatientId == id) || ctx.Examinations.Any(d => d.PatientId == id) ||
                         ctx.Messages.Any(d => d.PatientId == id) || ctx.Rendezvouses.Any(d => d.PatientId == id);

                if (b)
                {
                    return(Extensions.DataBaseResult.Referanced);
                }

                ctx.Patients.Remove(patient);
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
 public Department Select(string name)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.Departments.FirstOrDefault(d => d.Name == name));
     }
 }
Example #13
0
        public Extensions.DataBaseResult Update(Doctor newInfoDoctor)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Doctors.Any(d => d.TcNo == newInfoDoctor.TcNo && d.Id != newInfoDoctor.Id))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }
                Doctor doctor = ctx.Doctors.FirstOrDefault(d => d.Id == newInfoDoctor.Id);
                if (doctor == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                doctor.Name               = newInfoDoctor.Name;
                doctor.Surname            = newInfoDoctor.Surname;
                doctor.BirthDay           = newInfoDoctor.BirthDay;
                doctor.TcNo               = newInfoDoctor.TcNo;
                doctor.RegistrationNumber = newInfoDoctor.RegistrationNumber;
                doctor.DepartmentId       = newInfoDoctor.DepartmentId;
                doctor.DegreeId           = newInfoDoctor.DegreeId;
                doctor.MotherName         = newInfoDoctor.MotherName;
                doctor.FatherName         = newInfoDoctor.FatherName;
                doctor.IsActive           = newInfoDoctor.IsActive;
                doctor.Password           = newInfoDoctor.Password;
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #14
0
        public Extensions.DataBaseResult Delete(int id)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Doctor doctor = ctx.Doctors.FirstOrDefault(d => d.Id == id && d.IsActive);
                if (doctor == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                bool b = ctx.Rendezvouses.Any(r => r.DoctorId == id && r.IsActive) ||
                         ctx.Examinations.Any(e => e.DoctorId == id && e.IsActive);
                if (b)
                {
                    return(Extensions.DataBaseResult.Referanced);
                }


                doctor.IsActive = false;
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #15
0
 public List <DoctorMail> DoctorMails(bool?isActive = true)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.DoctorMails.Include("Doctor").Where(c => isActive == null || c.IsActive == isActive).ToList());
     }
 }
 public List <Examination> Examinations(DateTime?time, int doctorId, int?patientId, bool?isActive = true,
                                        bool includeDiagnosis = false)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(includeDiagnosis
             ? ctx.Examinations.Include("Patient")
                .Include("Diagnosis")
                .Where(
                    c =>
                    (time == null ||
                     (c.Time.Year == time.Value.Year && c.Time.Month == time.Value.Month &&
                      c.Time.Day == time.Value.Day)) && (isActive == null || c.IsActive == isActive) &&
                    (c.DoctorId == doctorId) && (patientId == null || c.PatientId == patientId))
                .OrderBy(e => e.RendezvousId)
                .ToList()
             : ctx.Examinations.Include("Patient")
                .Where(
                    c =>
                    (time == null ||
                     (c.Time.Year == time.Value.Year && c.Time.Month == time.Value.Month &&
                      c.Time.Day == time.Value.Day)) && (isActive == null || c.IsActive == isActive) &&
                    (c.DoctorId == doctorId) && (patientId == null || c.PatientId == patientId))
                .OrderBy(e => e.RendezvousId)
                .ToList());
     }
 }
Example #17
0
 public Holiday Select(int id)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.Holidays.FirstOrDefault(d => d.Id == id));
     }
 }
 public Degree Select(int id)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.Degrees.FirstOrDefault(d => d.Id == id));
     }
 }
Example #19
0
        public Extensions.DataBaseResult Update(Holiday newInfoHoliday)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Holidays.Any(d => d.Name == newInfoHoliday.Name))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }

                Holiday holiday = ctx.Holidays.FirstOrDefault(b => b.Id == newInfoHoliday.Id);

                if (holiday == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                holiday.Name  = newInfoHoliday.Name;
                holiday.Year  = newInfoHoliday.Year;
                holiday.Month = newInfoHoliday.Month;
                holiday.Day   = newInfoHoliday.Day;
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
 public LaboratoryRequestType Select(int id)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.LaboratoryRequestTypes.Include("LaboratoryItemUnit").FirstOrDefault(d => d.Id == id));
     }
 }
Example #21
0
 public List <BloodGroup> BloodGroups(bool?isActive = true)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.BloodGroups.Where(b => isActive == null || b.IsActive == isActive).ToList());
     }
 }
Example #22
0
 public RendezvousTime Select(int id)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.RendezvousTimes.FirstOrDefault(d => d.Id == id));
     }
 }
 public List <LaboratoryItemUnit> LaboratoryItemUnits(bool?isActive = true)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.LaboratoryItemUnits.Where(c => isActive == null || c.IsActive == isActive).ToList());
     }
 }
Example #24
0
 public List <RendezvousTime> RendezvousTimes(bool?isActive = true)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.RendezvousTimes.Where(c => isActive == null || c.IsActive == isActive).ToList());
     }
 }
Example #25
0
 public Diagnosis Select(string name)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.Diagnoses.Include("Department").FirstOrDefault(d => d.Name == name));
     }
 }
 public List <City> Citys(bool?isActive = true)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.Cities.Where(c => isActive == null || c.IsActive == isActive).ToList());
     }
 }
Example #27
0
        public Extensions.DataBaseResult Delete(int id)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Diagnosis diagnosis = ctx.Diagnoses.FirstOrDefault(d => d.Id == id);

                if (diagnosis == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                bool b = ctx.Examinations.Any(d => d.DiagnosisId == id);

                if (b)
                {
                    return(Extensions.DataBaseResult.Referanced);
                }

                ctx.Diagnoses.Remove(diagnosis);
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
        public Extensions.DataBaseResult Update(City newInfoCity)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Cities.Any(d => d.Name == newInfoCity.Name))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }
                City city = ctx.Cities.FirstOrDefault(b => b.Id == newInfoCity.Id);

                if (city == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                city.Name     = newInfoCity.Name;
                city.IsActive = newInfoCity.IsActive;
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
 public List <DoctorPhone> DoctorPhones(bool?isActive = true)
 {
     using (MySqlHealthContext ctx = new MySqlHealthContext())
     {
         return(ctx.DoctorPhones.Include("Doctor").ToList());
     }
 }
        public Extensions.DataBaseResult Delete(int id)
        {
            using (MySqlHealthContext ctx = new MySqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Medicament medicament = ctx.Medicaments.FirstOrDefault(d => d.Id == id);
                if (medicament == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }
                bool b = ctx.PrescriptionItems.Any(d => d.MedicamentId == id);

                if (b)
                {
                    return(Extensions.DataBaseResult.Referanced);
                }

                ctx.Medicaments.Remove(medicament);
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }