Exemplo n.º 1
0
 public List <Patient> AllPatients()
 {
     using (var connection = SqlConnectionFactory.GetConnectionString())
     {
         try
         {
             var result = connection.Query <Patient>("GetAllPatients", commandType:
                                                     CommandType.StoredProcedure);
             return(result.ToList());
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 2
0
 public List <Staff> GetAllStaff()
 {
     using (var connection = SqlConnectionFactory.GetConnectionString())
     {
         try
         {
             var result = connection.Query <Staff>("[dbo].[GetAllStaff]",
                                                   commandType: CommandType.StoredProcedure);
             return(result.ToList());
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 3
0
 //Update
 public Patient GetPatientDetails(int patientID)
 {
     using (var connection = SqlConnectionFactory.GetConnectionString())
     {
         try
         {
             var result = connection.Query <Patient>("[dbo].[GetPatientByID]",
                                                     new
             {
                 PatientID = patientID
             },
                                                     commandType: CommandType.StoredProcedure);
             return(result.FirstOrDefault());
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 4
0
 //Update
 public Staff GettingStaffDetails(int StaffID)
 {
     using (var connection = SqlConnectionFactory.GetConnectionString())
     {
         try
         {
             var result = connection.Query <Staff>("[dbo].[GetStaffByID]",
                                                   new
             {
                 StaffID = StaffID
             },
                                                   commandType: CommandType.StoredProcedure);
             return(result.FirstOrDefault());
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 5
0
 public Patient UpdateOfPatient(Patient patient)
 {
     using (var connection = SqlConnectionFactory.GetConnectionString())
     {
         try
         {
             var result = connection.Query <Patient>("[dbo].[UpdatePatient]",
                                                     new
             {
                 PatientID = patient.PatientID,
                 FirstName = patient.FirstName,
                 LastName  = patient.LastName,
                 NhsNumber = patient.NhsNumber
             },
                                                     commandType: CommandType.StoredProcedure);
             return(result.FirstOrDefault());
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 6
0
        public void InsertPatient(Patient patient)
        {
            using (var connection = SqlConnectionFactory.GetConnectionString())
            {
                try
                {
                    connection.Query("[dbo].[InsertPatient]",
                                     new
                    {
                        FirstName   = patient.FirstName,
                        LastName    = patient.LastName,
                        DateOfBirth = patient.DateOfBirth,
                        NhsNumber   = patient.NhsNumber
                    },

                                     commandType: CommandType.StoredProcedure);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 7
0
        public void InsertAppointment(Appointment appointment)
        {
            using (var connection = SqlConnectionFactory.GetConnectionString())
            {
                try
                {
                    connection.Query("[dbo].[InsertAppointment]",
                                     new
                    {
                        PatientID         = appointment.PatientID,
                        StaffID           = appointment.SelectedStaff,
                        AppointmentDate   = appointment.AppointmentDate,
                        AppointmentTimeID = appointment.SelectedAppointmentTime
                    },

                                     commandType: CommandType.StoredProcedure);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 8
0
 public Staff InsertStaff(Staff staff)
 {
     using (var connection = SqlConnectionFactory.GetConnectionString())
     {
         try
         {
             var result = connection.Query <Staff>("InsertStaff",
                                                   new
             {
                 FirstName   = staff.FirstName,
                 LastName    = staff.LastName,
                 StartDate   = staff.StartDate,
                 DateOfBirth = staff.DateOfBirth,
                 StaffTypeID = staff.StaffTypeID
             },
                                                   commandType: CommandType.StoredProcedure);
             return(result.FirstOrDefault());
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }