Exemple #1
0
 //update
 public Staff UpdateOfStaff(Staff staff)
 {
     using (var connection = SqlConnectionFactory.GetConnectionString())
     {
         try
         {
             var result = connection.Query <Staff>("[dbo].[UpdateStaff]",
                                                   new
             {
                 StaffID     = staff.StaffID,
                 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;
         }
     }
 }
        public List <SelectListItem> GetAllAppointments()
        {
            using (var connection = SqlConnectionFactory.GetConnectionString())
            {
                try
                {
                    var AllAppointmentTimes = connection.Query <AppointmentTime>("[dbo].[GetAllAppointments]",
                                                                                 commandType: CommandType.StoredProcedure);

                    var appointmentList = new List <SelectListItem>();

                    foreach (var oneAppointmentTime in AllAppointmentTimes)
                    {
                        var selectListItem = new SelectListItem();
                        selectListItem.Text  = oneAppointmentTime.AppointmentDescription;
                        selectListItem.Value = oneAppointmentTime.AppointmentTimeID.ToString();

                        appointmentList.Add(selectListItem);
                    }

                    return(appointmentList);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        public List <SelectListItem> GetAllStaff()
        {
            using (var connection = SqlConnectionFactory.GetConnectionString())
            {
                try
                {
                    var AllStaff = connection.Query <Staff>("[dbo].[GetAllStaff]", commandType: CommandType.StoredProcedure);

                    var staffList = new List <SelectListItem>();

                    foreach (var oneStaff in AllStaff)
                    {
                        var selectListItem = new SelectListItem();
                        selectListItem.Text  = oneStaff.LastName;
                        selectListItem.Value = oneStaff.StaffID.ToString();

                        staffList.Add(selectListItem);
                    }

                    return(staffList);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
 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;
         }
     }
 }
Exemple #5
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;
         }
     }
 }
 //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;
         }
     }
 }
Exemple #7
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;
         }
     }
 }
 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;
         }
     }
 }
        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;
                }
            }
        }
        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;
                }
            }
        }