Exemplo n.º 1
0
 public bool UpdatePatient(ref PatientBDO patientBDO,
     ref string massage)
 {
     massage = "Patient updated successfully";
     var ret = true;
     using (var PHEntites = new PublicHospitalEntities())
     {
         var patientId = patientBDO.id;
         var patientInDb = (from a
                          in PHEntites.Patient
                          where a.id == patientId
                          select a).FirstOrDefault();
         if (patientInDb == null)
         {
             throw new Exception("No patient with id " +
                                 patientBDO.id);
         }
         patientInDb.firstName = patientBDO.firstName;
         patientInDb.lastName = patientBDO.lastName;
         patientInDb.city = patientBDO.city;
         patientInDb.zip = patientBDO.zip;
         patientInDb.street = patientBDO.street;
         patientInDb.streetNr = patientBDO.streetNr;
         patientInDb.phoneNr = patientBDO.phoneNr;
         patientInDb.dateOfBirth = patientBDO.dateOfBirth;
         //without username and pass
         PHEntites.Patient.Attach(patientInDb);
         PHEntites.Entry(patientInDb).State = System.Data.Entity.EntityState.Modified;
         var num = PHEntites.SaveChanges();
         if (num != 1)
         {
             ret = false;
             massage = "Patient was not updated";
         }
     }
     return ret;
 }
Exemplo n.º 2
0
 public bool UpdateAdmin(ref AdminBDO adminBDO,
     ref string massage)
 {
     massage = "Admin updated successfully";
     var ret = true;
     using (var PHEntites = new PublicHospitalEntities())
     {
         var adminId = adminBDO.id;
         var adminInDb = (from a
                          in PHEntites.Admin
                          where a.id == adminId
                          select a).FirstOrDefault();
         if (adminInDb == null)
         {
             throw new Exception("No admin with id " +
                                 adminBDO.id);
         }
         adminInDb.firstName = adminBDO.firstName;
         adminInDb.lastName = adminBDO.lastName;
         adminInDb.city = adminBDO.city;
         adminInDb.zip = adminBDO.zip;
         adminInDb.street = adminBDO.street;
         adminInDb.streetNr = adminBDO.streetNr;
         adminInDb.phoneNr = adminBDO.phoneNr;
         //without username and pass
         PHEntites.Admin.Attach(adminInDb);
         PHEntites.Entry(adminInDb).State = System.Data.Entity.EntityState.Modified;
         var num = PHEntites.SaveChanges();
         if (num != 1)
         {
             ret = false;
             massage = "Admin was not updated";
         }
     }
     return ret;
 }
Exemplo n.º 3
0
 public bool UpdateVisit(ref VisitBDO VisitBDO)
 {
     var ret = true;
     using (var PHEntites = new PublicHospitalEntities())
     {
         var VisitId = VisitBDO.id;
         var VisitInDb = (from a
                          in PHEntites.Visit
                                where a.Ap_Id == VisitId
                                select a).FirstOrDefault();
         if (VisitInDb == null)
         {
             throw new Exception("No Visit with id " +
                                 VisitBDO.id);
         }
         VisitInDb.Ap_Id = VisitBDO.id;
         VisitInDb.advice = VisitBDO.advice;
         VisitInDb.symptom = VisitBDO.symptom;
         VisitInDb.patientProblem = VisitBDO.patientProblem;
         VisitInDb.rowVersion = VisitBDO.rowVersion;
         //without username and pass
         PHEntites.Visit.Attach(VisitInDb);
         PHEntites.Entry(VisitInDb).State = System.Data.Entity.EntityState.Modified;
         var num = PHEntites.SaveChanges();
         VisitBDO.rowVersion = VisitInDb.rowVersion;
         if (num != 1)
         {
             ret = false;
         }
     }
     return ret;
 }
Exemplo n.º 4
0
        public bool Updateappointment(ref AppointmentBDO appointmentBDO,
        ref string massage)
        {
            massage = "appointment updated successfully";
            var ret = true;
            using (var PHEntites = new PublicHospitalEntities())
            {
                var appointmentId = appointmentBDO.id;
                var appointmentInDb = (from a
                in PHEntites.Appointment
                                       where a.id == appointmentId
                                       select a).FirstOrDefault();
                if (appointmentInDb == null)
                {
                    throw new Exception("No appointment with id " +
                    appointmentBDO.id);
                }
                appointmentInDb.id = appointmentBDO.id;
                appointmentInDb.time = appointmentBDO.time.Date;
                appointmentInDb.serviceType = appointmentBDO.serviceType;
                appointmentInDb.idPatient = appointmentBDO.patient.id;
                appointmentInDb.idDoctor = appointmentBDO.patient.id;
                appointmentInDb.rowVersion = appointmentBDO.rowVersion;
                PHEntites.Appointment.Attach(appointmentInDb);
                PHEntites.Entry(appointmentInDb).State = System.Data.Entity.EntityState.Modified;
                var num = PHEntites.SaveChanges();

                appointmentBDO.rowVersion = appointmentInDb.rowVersion;
                if (num != 1)
                {
                    ret = false;
                    massage = "appointment was not updated";
                }
            }
            return ret;
        }