Ejemplo n.º 1
0
 public static bool DeactivateDoctor(int doctorId, int hospitalId)
 {
     using (LinqDBDataContext data = new LinqDBDataContext())
     {
         Doctor_Hospital doctor_hospital = (from d in data.Doctors
                                            from dh in d.Doctor_Hospitals
                                            where d.Doctor_ID == doctorId &&
                                            dh.Hospital_ID == hospitalId
                                            select dh).SingleOrDefault();
         if (doctor_hospital != null)
         {
             doctor_hospital.Is_Active = false;
             data.SubmitChanges();
         }
         return(true);
     }
 }
Ejemplo n.º 2
0
        public static bool InsertDoctor(DoctorModel model)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                using (LinqDBDataContext data = new LinqDBDataContext())
                {
                    string workingDay = "";
                    foreach (int wd in model.WorkingDay)
                    {
                        workingDay = workingDay + wd + ',';
                    }
                    if (workingDay.Length > 0)
                    {
                        workingDay = workingDay.Substring(0, workingDay.Length - 1);
                    }
                    Doctor doctor = new Doctor()
                    {
                        First_Name  = model.FirstName,
                        Last_Name   = model.LastName,
                        Gender      = model.Gender == 1 ? true : false,
                        Degree      = model.Degree,
                        Experience  = model.Experience,
                        Working_Day = string.IsNullOrEmpty(workingDay) ? null : workingDay,
                        Is_Active   = true
                    };
                    data.Doctors.InsertOnSubmit(doctor);
                    data.SubmitChanges();

                    if (!string.IsNullOrEmpty(model.PhotoFilePath))
                    {
                        Photo photo = new Photo()
                        {
                            File_Path       = model.PhotoFilePath,
                            Caption         = model.LastName + " " + model.FirstName,
                            Add_Date        = DateTime.Now,
                            Doctor_ID       = doctor.Doctor_ID,
                            Uploaded_Person = model.UploadedPerson,
                            Is_Active       = true
                        };

                        data.Photos.InsertOnSubmit(photo);
                        data.SubmitChanges();
                    }

                    foreach (int specilityId in model.SpecialityList)
                    {
                        Doctor_Speciality ds = new Doctor_Speciality()
                        {
                            Doctor_ID     = doctor.Doctor_ID,
                            Speciality_ID = specilityId,
                            Is_Active     = true
                        };
                        data.Doctor_Specialities.InsertOnSubmit(ds);
                        data.SubmitChanges();
                    }
                    Doctor_Hospital dh = new Doctor_Hospital()
                    {
                        Doctor_ID   = doctor.Doctor_ID,
                        Hospital_ID = model.HospitalID,
                        Is_Active   = true
                    };
                    data.Doctor_Hospitals.InsertOnSubmit(dh);
                    data.SubmitChanges();
                    ts.Complete();
                }
            }
            return(true);
        }