public ActionResult Create(AppointmentModel Appt) { try { AppointmentRepository.Create(Appt); return(RedirectToAction(nameof(Index))); } catch (Exception e) { ModelState.AddModelError("", e.Message); return(View()); } }
public void RefreshAppRepository() { using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); SqlCommand cmdShowAllAppointments = new SqlCommand("SP_SHOW_ALL_APPOINTMENTS", con); cmdShowAllAppointments.CommandType = CommandType.StoredProcedure; SqlDataReader reader = cmdShowAllAppointments.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DateTime appointmentDate = Convert.ToDateTime(reader["APPOINTMENT_DATE"]); string appointmentStartTime = reader["START_TIME"].ToString(); string appointmentEndTime = reader["END_TIME"].ToString(); string appointmentNotes = reader["NOTES"].ToString(); string customerPhone = reader["PHONE_NUMBER"].ToString(); appointRepo.Create(appointmentDate, appointmentStartTime, appointmentEndTime, appointmentNotes, customerPhone); } } } }