Ejemplo n.º 1
0
        public static void AddPatient(View_Patient pat)
        {
            try
            {
                using (var ctx = new ClinicalFormEntities())
                {
                    //Get student name of string type
                    ctx.Database.ExecuteSqlCommand("op_InsertPatient @FirstName, @LastName, @DateOfBirth, @Country, @Diseases, @Phone, @BloodType ",
                                                   new SqlParameter("FirstName", pat.FirstName),
                                                   new SqlParameter("LastName", pat.LastName),
                                                   new SqlParameter("DateOfBirth", pat.DateOfBirth),
                                                   new SqlParameter("Country", pat.Country),
                                                   new SqlParameter("Diseases", pat.Diseases),
                                                   new SqlParameter("Phone", pat.Phone),
                                                   new SqlParameter("BloodType", pat.BloodType)
                                                   );

                    AuditCRUD.CreateAuditMesssageAndInsertMessage(false, "FINISHED NEW PATIENT INSERTION", "PatientsController");
                }
            }
            catch (Exception ex)
            {
                AuditCRUD.CreateAuditMesssageAndInsertMessage(true, "ERROR ON NEW PATIENT INSERTION", "PatientsController", ex.StackTrace);
                throw;
            }
        }
Ejemplo n.º 2
0
        public static void UpdatePatient(int key, View_Patient patient)
        {
            try
            {
                using (var ctx = new ClinicalFormEntities())
                {
                    View_Patient pat = (from p in ctx.Patient
                                        where p.id == key
                                        select new View_Patient {
                        id = p.id,
                        BloodType = p.BloodType.Id.ToString(),
                        Country = p.Country.Id.ToString(),
                        DateOfBirth = p.DateOfBirth,
                        Diseases = p.Diseases,
                        FirstName = p.FirstName,
                        LastName = p.LastName,
                        Phone = p.Phone,
                    }).FirstOrDefault();


                    //Manually mapping the patient, no time for fancy pants mapper
                    pat.FirstName   = !String.IsNullOrEmpty(patient.FirstName) ? patient.FirstName : pat.FirstName;
                    pat.LastName    = !String.IsNullOrEmpty(patient.LastName) ? patient.LastName : pat.LastName;
                    pat.DateOfBirth = !String.IsNullOrEmpty(patient.DateOfBirth) ? patient.DateOfBirth : pat.DateOfBirth;
                    pat.Diseases    = !String.IsNullOrEmpty(patient.Diseases) ? patient.LastName : pat.Diseases;
                    pat.Phone       = !String.IsNullOrEmpty(patient.Phone) ? patient.Phone : pat.Phone;
                    pat.Country     = !String.IsNullOrEmpty(patient.Country) ? patient.Country : pat.Country;
                    pat.BloodType   = !String.IsNullOrEmpty(patient.BloodType) ? patient.BloodType : pat.BloodType;



                    //Get student name of string type
                    ctx.Database.ExecuteSqlCommand("op_UpdatePatient @id, @FirstName, @LastName, @DateOfBirth, @Country, @Diseases, @Phone, @BloodType ",
                                                   new SqlParameter("id", key),
                                                   new SqlParameter("FirstName", pat.FirstName),
                                                   new SqlParameter("LastName", pat.LastName),
                                                   new SqlParameter("DateOfBirth", pat.DateOfBirth),
                                                   new SqlParameter("Country", pat.Country),
                                                   new SqlParameter("Diseases", pat.Diseases),
                                                   new SqlParameter("Phone", pat.Phone),
                                                   new SqlParameter("BloodType", pat.BloodType)
                                                   );

                    AuditCRUD.CreateAuditMesssageAndInsertMessage(false, "FINISHED PATIENT UPDATE", "PatientsController");
                }
            }
            catch (Exception ex)
            {
                AuditCRUD.CreateAuditMesssageAndInsertMessage(true, "ERROR ON PATIENT UPDATE", "PatientsController", ex.StackTrace);
                throw;
            }
        }
        public ActionResult Update(int key, View_Patient patient)
        {
            try
            {
                //Audit log
                AuditCRUD.CreateAuditMesssageAndInsertMessage(false, "INITIATE PATIENT UPDATE", "PatientsController");

                PatientCRUD.UpdatePatient(key, patient);

                return(new HttpStatusCodeResult(200));
            }
            catch (Exception ex)
            {
                AuditCRUD.CreateAuditMesssageAndInsertMessage(true, "ERROR ON PATIENT UPDATE", "PatientsController", ex.StackTrace);
                return(new HttpStatusCodeResult(500));
            }
        }
        public ActionResult Post(View_Patient values)
        {
            try
            {
                //Audit log
                AuditCRUD.CreateAuditMesssageAndInsertMessage(false, "INITIATE NEW PATIENT INSERTION", "PatientsController");

                PatientCRUD.AddPatient(values);

                return(new HttpStatusCodeResult(200));
            }
            catch (Exception ex)
            {
                AuditCRUD.CreateAuditMesssageAndInsertMessage(true, "ERROR ON NEW PATIENT INSERTION", "PatientsController", ex.StackTrace);
                return(new HttpStatusCodeResult(500));
            }
        }