示例#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); }
        }
示例#2
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); }
 }
示例#3
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); }
 }
示例#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); }
 }
示例#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); }
 }
示例#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); }
 }
示例#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); }
 }
示例#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); }
 }
示例#9
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); }
 }
示例#10
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); }
 }
示例#11
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); }
 }
示例#12
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); }
        }