public async Task ReBookSlotAppointment() { const string contractor = "reBookContractor"; var woRef = AddWorkOrder(contractor); var initialSlotSeed = new AppointmentSeedModel("AM", DateTime.UtcNow, DateTime.UtcNow.AddHours(1)); var expectedSlotSeed = new AppointmentSeedModel("PM", DateTime.UtcNow.AddHours(5), DateTime.UtcNow.AddHours(6)); var allAppointments = new[] { initialSlotSeed, expectedSlotSeed }; var(code, appointments) = await GetAppointments(contractor, woRef, allAppointments); code.Should().Be(HttpStatusCode.OK); var appointmentSlots = appointments.Single().Slots; appointmentSlots.Should().HaveCount(2); var initialSlot = appointmentSlots.Single(s => s.Description == initialSlotSeed.Description); var expectedSlot = appointmentSlots.Single(s => s.Description == expectedSlotSeed.Description); await RequestAppointment(woRef, initialSlot.Reference); await RequestAppointment(woRef, expectedSlot.Reference); using var ctx = GetContext(); var db = ctx.DB; var bookedAppointment = await db.Appointments.SingleAsync(a => a.WorkOrderId == woRef); bookedAppointment.StartTime.Should().Be(expectedSlotSeed.StartTime); bookedAppointment.EndTime.Should().Be(expectedSlotSeed.EndTime); }
public async Task ListForWorkOrderForDates() { const string contractor = "contractor"; var woRef = AddWorkOrder(contractor); var expectedAppointment = new AppointmentSeedModel("AM", DateTime.UtcNow, DateTime.UtcNow.AddHours(1)); var(code, appointments) = await GetAppointments(contractor, woRef, expectedAppointment); code.Should().Be(HttpStatusCode.OK); var appointment = appointments.Should().ContainSingle().Which.Slots.Should().ContainSingle().Which; appointment.Description.Should().Be(expectedAppointment.Description); appointment.Start.Should().Be(expectedAppointment.StartTime.ToTime()); appointment.End.Should().Be(expectedAppointment.EndTime.ToTime()); }
public async Task BookSlotAppointment() { const string contractor = "contractor"; var woRef = AddWorkOrder(contractor); var expectedAppointment = new AppointmentSeedModel("AM", DateTime.UtcNow, DateTime.UtcNow.AddHours(1)); var(code, appointments) = await GetAppointments(contractor, woRef, expectedAppointment); code.Should().Be(HttpStatusCode.OK); var appointment = appointments.Single().Slots.Single(); const string expectedNotes = "notes"; var request = new RequestAppointment { WorkOrderReference = new Reference { ID = woRef.ToString() }, AppointmentReference = new Reference { ID = appointment.Reference }, Notes = expectedNotes }; code = await Post($"/api/v2/appointments", request); code.Should().Be(HttpStatusCode.OK); using var ctx = GetContext(); var db = ctx.DB; var bookedAppointment = await db.Appointments.SingleAsync(a => a.WorkOrderId == woRef); bookedAppointment.StartTime.Should().Be(expectedAppointment.StartTime); bookedAppointment.EndTime.Should().Be(expectedAppointment.EndTime); bookedAppointment.AppointmentNote.Should().Be(expectedNotes); var notes = await db.JobStatusUpdates.SingleAsync(jsu => jsu.RelatedWorkOrderId == woRef); notes.TypeCode.Should().Be(JobStatusUpdateTypeCode.Other_0); notes.OtherType.Should().Be(CustomJobStatusUpdates.AddNote); notes.Comments.Should().Be(expectedNotes); var(woCode, workOrderResponse) = await Get <RepairsApi.V2.Boundary.WorkOrderResponse>($"/api/v2/workOrders/{woRef}"); woCode.Should().Be(HttpStatusCode.OK); workOrderResponse.Appointment.Note.Should().Be(expectedNotes); }