public ActionResult Index(AppointmentViewModel model) { AppointmentRequest request = new AppointmentRequest { AppointmentID = model.Appointment.ID }; AppointmentResponse response = appointmentService.GetAppointment(request); model = new AppointmentViewModel { Appointment = response.Appointment, Message = response.Message }; return View(model); }
public void GetAppointmentTest() { // Arrange IList<Appointment> appointments = new List<Appointment> { new Appointment() { ID = 1 } }; // Arrange IAppointmentRepository repository = new AppointmentRepository(appointments); IAppointmentService service = new AppointmentService(repository); // Arrange AppointmentRequest request = new AppointmentRequest() { AppointmentID = 1 }; // Act AppointmentResponse result = service.GetAppointment(request); // Assert Assert.AreEqual(appointments[0], result.Appointment); Assert.IsTrue(result.Success); }
public AppointmentResponse GetAppointment(AppointmentRequest appointmentRequest) { // Create a response object AppointmentResponse response = new AppointmentResponse(); try { Appointment appointment = repository.GetByID(appointmentRequest.AppointmentID); response.Appointment = appointment; response.Success = true; response.Message = appointment.ID + " was found"; } catch(Exception ex) { response.Success = false; response.Message = ex.Message; } // Return the response object return response; }