//APPOINTMENT FUNCTIONALITIES public Appointment saveAppointment(int petId, int customerId, int serviceId, int vetId, DateTime date) { Appointment appointment = new Appointment { ID = idGenerator <Appointment>(appointmentsRepository), PetID = petId, CustomerID = customerId, ServiceID = serviceId, VetID = vetId, Date = date }; Vet vet = vetRepository.FindOne(vetId); return(appointmentsRepository.SaveWithVet(appointment, vet)); }
public void TestAppointmentsRepository() { Assert.AreEqual(appointmentsRepository.Size(), 0); System.DateTime dateTime1 = System.DateTime.Parse("12/10/2021 09:10"); System.DateTime dateTime2 = System.DateTime.Parse("02/01/2026 15:00"); Appointment app1 = new Appointment() { ID = 1, PetID = 1, CustomerID = 1, ServiceID = 1, VetID = 1, Date = dateTime1 }; Vet vet1 = new Vet() { ID = 1, Name = "Sisi Rocky", Schedule = "09:00-10:15" }; Appointment app2 = new Appointment() { ID = 2, PetID = 2, CustomerID = 2, ServiceID = 2, VetID = 2, Date = dateTime2 }; Vet vet2 = new Vet() { ID = 2, Name = "Lori Cori", Schedule = "14:00-18:00" }; //adding 2 appointments to the repository appointmentsRepository.SaveWithVet(app1, vet1); appointmentsRepository.SaveWithVet(app2, vet2); Assert.AreEqual(appointmentsRepository.Size(), 2); //test the find all List <Appointment> allApointments = new List <Appointment>(); foreach (Appointment app in appointmentsRepository.FindAll()) { allApointments.Add(app); } Assert.AreEqual(allApointments[0], app1); Assert.AreEqual(allApointments[1], app2); //test the find one Appointment appointmentFound = appointmentsRepository.FindOne(app1.ID); Assert.AreEqual(appointmentFound, app1); }