ardalis / pluralsight-ddd-fundamentals

Sample code for the Pluralsight DDD Fundamentals course by Julie Lerman and Steve "ardalis" Smith

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Appointments not showing in Schedule [June 2023]

GraemeWellington opened this issue · comments

I have downloaded latest pluralsight-ddd-fundamentals-main.zip and started the apps with docker. However when I start ddd.frontdesk.blazor in browser the Schedule is displayed for 30-09-2030 but no appointments. There are multiple rows of data in dbo.Appointments for this date. If I select a Client and Patient and double click in a blank space the Appointment Data appears in a modal but when Save clicked a notification appears but nothing still displays in the Schedule.

This might not be related but in the browser DevTools there are 2 messages under console:

 DevTools failed to load source map: Could not load content for http://localhost:5100/css/kendo/kendo.common.min.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:5100/css/kendo/kendo.default.min.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

dbo.Appointments.txt

Those files shouldn't matter too much. Are you able to see the DB calls being made? That should tell you something about what the app is trying to do under the covers. Troubleshooting steps:

  • Is EF using the SQL provider and talking to SQL?
  • What query is EF using?
  • What do you get when you run that query yourself?
  • Can you hit the API endpoint yourself and get data that way?

Basically the data needs to make it from the database to the API server to the Blazor Client code and finally be rendered to HTML. Any one of those transitions could fail so start from the database and try to find the failure point. HTH.

I have started from scratch and created both migrations and database updates.
I can confirm that I can get data via Swagger for all endpoints.
From Docker Desktop when I open ddd.frontdesk.blazor the Appointments page is displayed with Client: David Batten and Patient: Max.
No appointments appear for Monday, September 23, 2030. [The seeded data does correspond to this date].
However when I click 'Agenda' all the appointments are displayed correctly for Exam Room 1 / 2 /3.
Exam Room 1: 23 Monday September 2030 11:30 PM - 12:00 AM (WE} Darwin - Steve Smith
That might be a clue - When I click the 'Day' option the time slots displayed start at 7:00am and end 5:00pm.
So maybe the seeded appointments are outside this range and will not be displayed?
Also if I double click in any clear space in the schedule a modal pops up with Appointment Data Title: (WE) Max - David Batten etc. - I cannot see how I can add an appointment - also if I try and delete the appointment that pops up I get an error:

Access to fetch at 'http://localhost:5200/api/schedule/00000000-0000-0000-0000-000000000000/appointments/00000000-0000-0000-0000-000000000000' from origin 'http://localhost:5100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Thanks for taking the time to review this issue.

Adding an appointment is done by first choosing an owner/patient at the top and then just clicking (or maybe double-clicking) on a time in a room. That should bring up a modal window where you choose the appointment type. In the example you're giving with Max - David Batten that's trying to create a Wellness Exam (WE) and I assume you have Max/David chosen at the top. You should be able to save the modal and it should create the appointment, unless there's a problem (like CORS...).

The CORS issue is probably the root of your problem. Since this is a demo app you can just disable CORS by going into the middleware of the web API app and modifying CORS to allow anything.

See: https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-7.0

Here's where to make the change:
https://github.com/ardalis/pluralsight-ddd-fundamentals/blob/main/FrontDesk/src/FrontDesk.Api/Startup.cs#L87-L97

Add builder.AllowAnyHost() and remove the WithOrigins and SetIsOriginAllowed lines. See if that gets you past the CORS issue and gets other things working too hopefully.

I think I have narrowed the primary issue to being TimeZone related. I am operating in Adelaide Australia which is UTC+9:30.
In looking through the source code it appears that the TestDate was being initialised for UTC-4.00.
Thus appointments were being generated in non-available days/hours and therefore not appearing outside the available time slots. I adjusted the UTC time settings in several places and now am getting close and the appointments are appearing close to where they should be.
I have not used Docker much before but I note that if I run the apps via Visual Studio it uses my SQL Database and if I run Docker it uses another database within the containers - I am a slow learner so it took a while for the penny to drop!

The CORS problem was in Docker only and I made the suggested changes [note: I added builder.AllowAnyOrigin() not builder.AllowAnyHost() ]. I also need to reboot my PC and run Docker from a clean start for the FrontDesk to load the appointment data successfully.
So now I can get on with it!
Once again thanks for taking the time to review this issue.