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 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.º 3
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.º 4
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.º 5
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.º 6
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;
     }
 }