dotnet-presentations / blazor-workshop

Blazor workshop
https://aka.ms/blazorworkshop
MIT License
3.47k stars 1.54k forks source link

Placing order in lesson 2 will not work when following guide. #339

Closed 17steen closed 1 year ago

17steen commented 2 years ago

save point 2 Address.cs, in this file, required fields are defined. Those do not get filled up at any point by the Client, but the server will expect them, when the order is placed, to be filled in. This however never gets mentioned, and the tutorial goes on to lesson 3, which will then never work because the orders do not get added to the database. It gets very confusing as you then think to start from the following save point, and now it magically works. This is the result of those constraints to now be commented, without it being shown in the tutorial. This lead the learner to have a considerably lengthy headache not understanding what they did wrong. save point 3 Address.cs

catalincodes commented 2 years ago

Same issue. Tutorial says that if I click on Track link button next to the order it will go to my orders/

Only problem is that I never get to have any orders as they never get to the back-end. It's very confusing.

dotnetspark commented 2 years ago

@catalinp86 I haven't seen this issue. Mine works just fine. Could you share your repo?

dotnetspark commented 2 years ago

@17steen true that save-point sections -even 1st- have the required attributes. That should be fixed so it matches the docs. However, I would encourage to follow the tutorial while save-points is fixed.

catalincodes commented 2 years ago

I will try again, a 3rd time, this time on another machine and see if I reproduce it again (initially, it was on the work computer, so no github). This time, I'll clone it on my machine, take the state at end of the session 2, place it in a public github repo and add the first steps in session 3. If the problem is still there I will push the changes and leave it as is.

catalincodes commented 2 years ago

@catalinp86 I haven't seen this issue. Mine works just fine. Could you share your repo?

@ylr-research I have repeated once again, the same process:

  1. Taken the source code from 02-customize-a-pizza
  2. Added the MyOrders part from 03 Show Order Status
  3. Run the application once I've added the Rendering of the list of orders
  4. Observed that I can place an order, but no orders are displayed in the MyOrders page

It adds up, because after submitting the pizza order, when I enter the MyOrders page, when the HttpClient attempts to get the list of Pizza orders it comes back with an empty list. That's abnormal.

catalincodes commented 2 years ago

image

This is the state on the server-side of orders.

PS: I apologize @ylr-research , if the repo isn't perfectly clean (source-code only), but I was on a little time, but I wanted to get back to you, since I need to get better at it for work and I was recommended this tutorial.

DjinnYcs commented 2 years ago

I met same problem, and somehow magically it solved by itself. Firstly, I commented Address.cs as in 3rd save point and began to compare code lines of 3rd and then 2nd save points in debug mode. Breakpoints was chosen to check orders variables (as @catalinp86 mentioned), and I didn't find any obvious differences, BUT in debug mode the 2nd save point surprisely start working as expected in tutorial. It's worth noting, that I launched debugging during whole day, but issue was resolved only after put breakpoints and checking lines step by step. Strange bug.

rzmz commented 2 years ago

Anyone still struggling, the solution would be to comment out model validation attributes in BlazingPizza.Shared.Address.cs and re-create the database (just delete pizza.db and re-start the app).

catalincodes commented 2 years ago

I'll test that out @rzmz

neintoes commented 2 years ago

Thanks very much for this @17steen and @rzmz. I experienced the same issue as @catalinp86 . Commenting out model validation attributes didn't work initially but as you said re-creating the database got it all working again. Much appreciated.

csharpfritz commented 2 years ago

Yes, I think we need to roll-back the initial requirements attributes in Address.cs as a recommended fix to this

Gobbenobber commented 2 years ago

Just wanted to add I only created a new PR because I couldn't figure out how to contribute to the existing one that's 27 days old and is missing changes to save-points 01 and 02.