示例#1
0
        public void DeleteAdministrator(int id)
        {
            try
            {
                using (HospitalManagementSystemContext context = TypeFactory.Resolve <HospitalManagementSystemContext>())
                //using (HospitalManagementSystemContext context = new HospitalManagementSystemContext())
                {
                    Administrator administrator = context.Administrator.Include(p => p.Person).FirstOrDefault(p => p.Id == id);

                    if (administrator != null)
                    {
                        administrator.Person = context.Person.FirstOrDefault(p => p.Id == administrator.PersonId);

                        if (administrator.Person != null)
                        {
                            //Bad code: place holder
                            administrator.Person.Email    = "*****@*****.**";
                            administrator.Person.UserName = "******";
                            administrator.Person.Active   = false;
                        }
                    }

                    context.SaveChanges();
                }
            }
            catch (System.Exception ex)
            {
                //throw ex;
            }
        }
示例#2
0
        public void SaveAdministrator(Administrator administrator)
        {
            try
            {
                using (HospitalManagementSystemContext context = TypeFactory.Resolve <HospitalManagementSystemContext>())
                //using (HospitalManagementSystemContext context = new HospitalManagementSystemContext())
                {
                    if (administrator.Id > 0)
                    {
                        Administrator savedAdministrator = context.Administrator.FirstOrDefault(p => p.Id == administrator.Id);

                        if (savedAdministrator != null)
                        {
                            savedAdministrator = administrator;
                        }
                    }
                    else
                    {
                        context.Administrator.Add(administrator);
                    }
                    context.SaveChanges();
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
        public void SaveNurse(Nurse nurse)
        {
            try
            {
                using (HospitalManagementSystemContext context = TypeFactory.Resolve <HospitalManagementSystemContext>())
                //using (HospitalManagementSystemContext context = new HospitalManagementSystemContext())
                {
                    if (nurse.Id > 0)
                    {
                        Nurse savedNurse = context.Nurse.FirstOrDefault(p => p.Id == nurse.Id);

                        if (savedNurse != null)
                        {
                            savedNurse = nurse;
                        }
                    }
                    else
                    {
                        context.Nurse.Add(nurse);
                    }
                    context.SaveChanges();
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
        public void SaveDoctor(Doctor doctor)
        {
            try
            {
                using (HospitalManagementSystemContext context = TypeFactory.Resolve <HospitalManagementSystemContext>())
                {
                    if (doctor.Id > 0)
                    {
                        Doctor savedDoctor = context.Doctor.FirstOrDefault(p => p.Id == doctor.Id);

                        if (savedDoctor != null)
                        {
                            savedDoctor = doctor;
                        }
                    }
                    else
                    {
                        context.Doctor.Add(doctor);
                    }
                    context.SaveChanges();
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
示例#5
0
        public void SavePorter(Porter porter)
        {
            try
            {
                using (HospitalManagementSystemContext context = TypeFactory.Resolve <HospitalManagementSystemContext>())
                {
                    if (porter.Id > 0)
                    {
                        Porter savedPorter = context.Porter.FirstOrDefault(p => p.Id == porter.Id);

                        if (savedPorter != null)
                        {
                            savedPorter = porter;
                        }
                    }
                    else
                    {
                        context.Porter.Add(porter);
                    }
                    context.SaveChanges();
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
示例#6
0
 public void SavePatient(Patient patient)
 {
     try
     {
         using (HospitalManagementSystemContext context = TypeFactory.Resolve <HospitalManagementSystemContext>())
         //using (HospitalManagementSystemContext context = new HospitalManagementSystemContext())
         {
             context.Patient.Add(patient);
             context.SaveChanges();
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }