public int AddAppointment(Appointment appointment) { using (var conn = new SqlConnection(PrescienceRxConnectionString)) { conn.Open(); using (var cmd = new SqlCommand(AddAppointmentSp, conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("@ProfessionalId", System.Data.SqlDbType.Int); cmd.Parameters["@ProfessionalId"].Value = appointment.ProfessionalId; cmd.Parameters.Add("@CustomerId", System.Data.SqlDbType.Int); cmd.Parameters["@CustomerId"].Value = appointment.CustomerId; cmd.Parameters.Add("@AppointmentDate", System.Data.SqlDbType.DateTime); cmd.Parameters["@AppointmentDate"].Value = appointment.AppointmentDate; cmd.Parameters.Add("@AppointmentStartTime", System.Data.SqlDbType.VarChar); cmd.Parameters["@AppointmentStartTime"].Value = appointment.AppointmentStartTime; cmd.Parameters.Add("@StatusId", System.Data.SqlDbType.Int); cmd.Parameters["@StatusId"].Value = appointment.StatusId; cmd.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int); cmd.Parameters["@CreatedBy"].Value = appointment.CreatedBy; cmd.Parameters.Add("@CreatedDate", System.Data.SqlDbType.DateTime); cmd.Parameters["@CreatedDate"].Value = DateTime.UtcNow; return Convert.ToInt16(cmd.ExecuteScalar()); } } }
public bool UpdateAppointment(Appointment appointment) { using (var conn = new SqlConnection(PrescienceRxConnectionString)) { conn.Open(); using (var cmd = new SqlCommand(UpdateAppointmentSp, conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("@AppointmentId", System.Data.SqlDbType.Int); cmd.Parameters["@AppointmentId"].Value = appointment.AppointmentId; cmd.Parameters.Add("@ProfessionalId", System.Data.SqlDbType.Int); cmd.Parameters["@ProfessionalId"].Value = appointment.ProfessionalId; cmd.Parameters.Add("@CustomerId", System.Data.SqlDbType.Int); cmd.Parameters["@CustomerId"].Value = appointment.CustomerId; cmd.Parameters.Add("@AppointmentDate", System.Data.SqlDbType.DateTime); cmd.Parameters["@AppointmentDate"].Value = appointment.AppointmentDate; cmd.Parameters.Add("@AppointmentStartTime", System.Data.SqlDbType.VarChar); cmd.Parameters["@AppointmentStartTime"].Value = appointment.AppointmentStartTime; cmd.Parameters.Add("@StatusId", System.Data.SqlDbType.Int); cmd.Parameters["@StatusId"].Value = appointment.StatusId; cmd.Parameters.Add("@StatusId", System.Data.SqlDbType.VarChar); cmd.Parameters["@StatusId"].Value = appointment.Comments; cmd.Parameters.Add("@UpdatedBy", System.Data.SqlDbType.Int); cmd.Parameters["@UpdatedBy"].Value = appointment.UpdatedBy; cmd.Parameters.Add("@UpdatedDate", System.Data.SqlDbType.DateTime); cmd.Parameters["@UpdatedDate"].Value = DateTime.UtcNow; return cmd.ExecuteNonQuery() > 0; } } }