Exemplo n.º 1
0
        public bool DeleteMedicine(int?id)
        {
            bool Result = true;

            try
            {
                Medicine medicine = GetMedicine(id);
                if (medicine == null)
                {
                    return(false);
                }
                using (var ctx = new DrugsContext())
                {
                    ctx.Configuration.ValidateOnSaveEnabled = false;
                    ctx.Medicines.Attach(medicine);
                    ctx.Entry(medicine).State = EntityState.Deleted;
                    ctx.SaveChanges();
                }
                GoogleDriveAPITool.DeleteGoogleFileByName(medicine.imagePath);
            }
            catch (Exception)
            {
                Result = false;
            }

            return(Result);
        }
Exemplo n.º 2
0
        public bool DeletePatient(int?id)
        {
            bool Result = true;

            try
            {
                Patient patient = GetPatient(id);
                if (patient == null)
                {
                    return(false);
                }
                using (var ctx = new DrugsContext())
                {
                    ctx.Configuration.ValidateOnSaveEnabled = false;
                    ctx.Patients.Attach(patient);
                    ctx.Entry(patient).State = EntityState.Deleted;
                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                Result = false;
            }

            return(Result);
        }
Exemplo n.º 3
0
 public Medicine GetMedicine(int?id)
 {
     using (var ctx = new DrugsContext())
     {
         return(ctx.Medicines.Find(id));
     }
 }
Exemplo n.º 4
0
        public bool DeleteDoctor(int?id)
        {
            bool Result = true;

            try
            {
                Doctor doctor = GetDoctor(id);
                if (doctor == null)
                {
                    return(false);
                }
                using (var ctx = new DrugsContext())
                {
                    ctx.Configuration.ValidateOnSaveEnabled = false;
                    ctx.Doctors.Attach(doctor);
                    ctx.Entry(doctor).State = EntityState.Deleted;
                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                Result = false;
            }

            return(Result);
        }
Exemplo n.º 5
0
 public IEnumerable <MedicineWrraper> GetAllNDC()
 {
     using (var ctx = new DrugsContext())
     {
         return(ctx.Name_NDC.ToList());
     }
 }
Exemplo n.º 6
0
 public Patient GetPatient(int?id)
 {
     using (var ctx = new DrugsContext())
     {
         return(ctx.Patients.Find(id));
     }
 }
Exemplo n.º 7
0
 public Prescription GetPrescription(int?id)
 {
     using (var ctx = new DrugsContext())
     {
         return(ctx.Prescriptions.Find(id));
     }
 }
Exemplo n.º 8
0
 public string GetNDCForMedicine(string genericName)
 {
     using (var ctx = new DrugsContext())
     {
         return(ctx.Name_NDC.Where(med => med.genericName == genericName).Select(med => med.NDCnumber).FirstOrDefault());
     }
 }
Exemplo n.º 9
0
 public Doctor GetDoctor(int?id)
 {
     using (var ctx = new DrugsContext())
     {
         return(ctx.Doctors.Find(id));
     }
 }
Exemplo n.º 10
0
        public IEnumerable <Patient> GetPatients(Func <Patient, bool> predicat = null)
        {
            using (var ctx = new DrugsContext())
            {
                if (predicat == null)
                {
                    return(ctx.Patients.ToList());
                }

                var patien = ctx.Patients.Where(predicat).ToList();
                return(patien);
            }
        }
Exemplo n.º 11
0
        public IEnumerable <Medicine> GetMedicines(Func <Medicine, bool> predicat = null)
        {
            using (var ctx = new DrugsContext())
            {
                if (predicat == null)
                {
                    return(ctx.Medicines.ToList());
                }

                var med = ctx.Medicines.Where(predicat).ToList();
                return(med);
            }
        }
Exemplo n.º 12
0
        public IEnumerable <Doctor> GetDoctors(Func <Doctor, bool> predicat = null)
        {
            using (var ctx = new DrugsContext())
            {
                if (predicat == null)
                {
                    return(ctx.Doctors.ToList());
                }

                var doc = ctx.Doctors.Where(predicat).ToList();
                return(doc);
            }
        }
Exemplo n.º 13
0
        public IEnumerable <Prescription> GetPrescriptions(Func <Prescription, bool> predicat = null)
        {
            using (var ctx = new DrugsContext())
            {
                if (predicat == null)
                {
                    return(ctx.Prescriptions.ToList());
                }


                var pres = ctx.Prescriptions.Where(predicat).ToList();
                return(pres);
            }
        }
Exemplo n.º 14
0
 public void UpdateDoctor(Doctor doctor)
 {
     try
     {
         using (var ctx = new DrugsContext())
         {
             ctx.Entry(doctor).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 15
0
 public void AddPrescription(Prescription prescription)
 {
     try
     {
         using (var ctx = new DrugsContext())
         {
             ctx.Prescriptions.Add(prescription);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 16
0
 public void AddPatient(Patient patient)
 {
     try
     {
         using (var ctx = new DrugsContext())
         {
             ctx.Patients.Add(patient);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 17
0
 public void AddDoctor(Doctor doctor)
 {
     try
     {
         using (var ctx = new DrugsContext())
         {
             ctx.Doctors.Add(doctor);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 18
0
 public void UpdatePatient(Patient patient)
 {
     try
     {
         using (var ctx = new DrugsContext())
         {
             ctx.Entry(patient).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 19
0
 public void AddMedicine(Medicine medicine, HttpPostedFileBase httpPostedFile)
 {
     try
     {
         using (var ctx = new DrugsContext())
         {
             ctx.Medicines.Add(medicine);
             ctx.SaveChanges();
         }
         GoogleDriveAPITool.FileUpload(httpPostedFile);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 20
0
 public void UpdateMedicine(Medicine medicine, HttpPostedFileBase httpPostedFile)
 {
     try
     {
         Medicine med = GetMedicine(medicine.Id);
         GoogleDriveAPITool.DeleteGoogleFileByName(med.imagePath);
         using (var ctx = new DrugsContext())
         {
             ctx.Entry(medicine).State = EntityState.Modified;
             ctx.SaveChanges();
         }
         GoogleDriveAPITool.FileUpload(httpPostedFile);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 21
0
        public void Dispose()
        {
            DrugsContext db = new DrugsContext();

            db.Dispose();
        }