Esempio n. 1
0
        public void AddImageDrugs(int id, HttpPostedFileBase file)
        {
            try
            {
                //  string path =
                // Path.Combine(HttpContext.Current.Server.MapPath("~/GoogleDriveFiles"),
                // Path.GetFileName(file.FileName));
                // file.SaveAs(path);
                using (var ctx = new mediDB())
                {
                    Medicine tmp = ctx.Drugs.First(m => m.Id == id);
                    if (tmp.ImageUrl == null)
                    {
                        tmp.ImageUrl = @"/images/" + file.FileName;
                        ctx.SaveChanges();

                        //Google Drive API
                        GoogleDriveAPIHelper gd = new GoogleDriveAPIHelper();
                        gd.UplaodFileOnDriveInFolder(file, file.FileName, "MedicinesImages");
                    }
                    else
                    {
                        GoogleDriveAPIHelper gd = new GoogleDriveAPIHelper();
                        gd.deleteFile(tmp.ImageUrl);
                        tmp.ImageUrl = @"/images/" + file.FileName;
                        ctx.SaveChanges();

                        //Google Drive API
                        gd.UplaodFileOnDriveInFolder(file, file.FileName, "MedicinesImages");
                    }
                }
            }
            catch (Exception e) { throw new Exception(e.Message); }
        }
Esempio n. 2
0
 public void InsertPrescription(Prescription p)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             ctx.Prescriptions.Add(p);
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 3
0
 public void InsertPatients(Patient p)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             ctx.Patients.Add(p);
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 4
0
 public void InsertDoctors(Doctor d)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             ctx.Doctors.Add(d);
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 5
0
 public void InsertAdmin(Admin a)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             ctx.Admin.Add(a);
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 6
0
 public void InsertDrugs(Medicine m)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             ctx.Drugs.Add(m);
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 7
0
 public void Removepatients(int id)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             Patient patient = ctx.Patients.Find(id);
             ctx.Patients.Remove(patient);
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 8
0
 public void RemoveDoctors(int id)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             Doctor doc = ctx.Doctors.Find(id);
             ctx.Doctors.Remove(doc);
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 9
0
 public IEnumerable <Admin> GetAdmin()
 {
     try
     {
         List <Admin> result = new List <Admin>();
         using (var ctx = new mediDB())
         {
             foreach (var admin in ctx.Admin)
             {
                 result.Add(admin);
             }
         }
         return(result);
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 10
0
 public void RemoveDrugs(int id)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             //Google Drive API
             GoogleDriveAPIHelper gd       = new GoogleDriveAPIHelper();
             Medicine             medicine = ctx.Drugs.Find(id);
             gd.deleteFile(medicine.ImageUrl);
             ctx.Drugs.Remove(medicine);
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 11
0
 public IEnumerable <Doctor> GetDoctors()
 {
     try
     {
         List <Doctor> result = new List <Doctor>();
         using (var ctx = new mediDB())
         {
             foreach (var doc in ctx.Doctors)
             {
                 result.Add(doc);
             }
         }
         return(result);
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 12
0
 public IEnumerable <Patient> GetPatients()
 {
     try
     {
         List <Patient> result = new List <Patient>();
         using (var ctx = new mediDB())
         {
             foreach (var patient in ctx.Patients)
             {
                 result.Add(patient);
             }
         }
         return(result);
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 13
0
 public IEnumerable <Prescription> GetPrescriptions()
 {
     try
     {
         List <Prescription> result = new List <Prescription>();
         using (var ctx = new mediDB())
         {
             foreach (var prescription in ctx.Prescriptions)
             {
                 result.Add(prescription);
             }
         }
         return(result);
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 14
0
 public IEnumerable <Medicine> GetMedicines()
 {
     try
     {
         List <Medicine> result = new List <Medicine>();
         using (var ctx = new mediDB())
         {
             foreach (var drug in ctx.Drugs)
             {
                 result.Add(drug);
             }
         }
         return(result);
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 15
0
 public void UpdatePatients(Patient patient, int id)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             Patient tmp = ctx.Patients.First(m => m.Id == id);
             tmp.FirstName   = patient.FirstName;
             tmp.LastName    = patient.LastName;
             tmp.DateOfBirth = patient.DateOfBirth;
             tmp.Phone       = patient.Phone;
             tmp.Email       = patient.Email;
             tmp.Drugs       = patient.Drugs;
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 16
0
 public Medicine GetMedicineByName(string name)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             foreach (var drug in ctx.Drugs)
             {
                 if (drug.CommercialName == name)
                 {
                     return(drug);
                 }
             }
         }
         return(null);
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 17
0
 public void UpdateDoctors(Doctor doc, int id)
 {
     try
     {
         using (var ctx = new mediDB())
         {
             Doctor tmp = ctx.Doctors.First(m => m.Id == id);
             tmp.LastName      = doc.LastName;
             tmp.FirstName     = doc.FirstName;
             tmp.Phone         = doc.Phone;
             tmp.LicenceNumber = doc.LicenceNumber;
             tmp.Expertist     = doc.Expertist;
             tmp.Email         = doc.Email;
             ctx.SaveChanges();
         }
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 18
0
 public IEnumerable <LicensedMedicine> GetMedicineByNdc(string ndc)
 {
     try
     {
         List <LicensedMedicine> result = new List <LicensedMedicine>();
         using (var ctx = new mediDB())
         {
             foreach (var LMedicine in ctx.LicensedMedicine)
             {
                 if (LMedicine.NDC == ndc)
                 {
                     result.Add(LMedicine);
                 }
             }
         }
         return(result);
     }
     catch (Exception e) { throw new Exception(e.Message); }
 }
Esempio n. 19
0
        public void UpdateDrugs(Medicine medicine, int id)
        {
            try
            {
                using (var ctx = new mediDB())
                {
                    Medicine tmp = ctx.Drugs.First(m => m.Id == id);
                    tmp.CommercialName     = medicine.CommercialName;
                    tmp.GenericName        = medicine.GenericName;
                    tmp.Producer           = medicine.Producer;
                    tmp.ActiveIngredients  = medicine.ActiveIngredients;
                    tmp.DoseCharacteristic = medicine.DoseCharacteristic;
                    tmp.ImageUrl           = medicine.ImageUrl;
                    ctx.SaveChanges();

                    //Google Drive API
                    GoogleDriveAPIHelper gd = new GoogleDriveAPIHelper();
                    //gd.deleteAllFiles(medicineId.ToString());
                    //gd.UplaodFileOnDriveInFolder(file, medicineId.ToString(), "cloudComputing");
                }
            }
            catch (Exception e) { throw new Exception(e.Message); }
        }