public IActionResult Index() { var viewmodel = new HRS.ViewModel.MakeAnAppointmentViewModel { clinics = hrsContext.GetClinics() }; return(View(viewmodel)); }
public IActionResult Add(HRS.ViewModel.MakeAnAppointmentViewModel makeAnAppointment) { using (SqlConnection sqlConnection = new SqlConnection(_connection)) { sqlConnection.Open(); string query = "INSERT INTO PatientAppointments(ClinicId,DoctorId,TimeId,TransactionDate) VALUES (@p1,@p2,@p3,@p4)"; SqlCommand sqlCommand = new SqlCommand(query, sqlConnection); sqlCommand.Parameters.AddWithValue("@p1", makeAnAppointment.ClinicId); sqlCommand.Parameters.AddWithValue("@p2", makeAnAppointment.DoctorId); sqlCommand.Parameters.AddWithValue("@p3", makeAnAppointment.TimeId); sqlCommand.Parameters.AddWithValue("@p4", makeAnAppointment.TransactionDate); sqlCommand.ExecuteNonQuery(); } return(RedirectToAction("Index")); }