C
C#2y ago
adoma

✅ Asp.Net Help

I'm working on a assignment and really need some help. We have to make a website where we can show high scores on 4 different games. I have 2 tables (games and Scores) with a one to many relation between them, where one game can have many scores. On the submit new high score page I have 4 input fields, the first one is a dropdown where I generated the game.titles from games table. My problem is when I try to submit the gameId always stays on 0.
28 Replies
Preda
Preda2y ago
Do you have a ParentID in your Game class (business layer)
adoma
adomaOP2y ago
i have the id property
Preda
Preda2y ago
I think you are using Agregation and Composition A player has a game and that game has more scores Your problem could be in the Business/Persistence layer since your ID isn t updating Have you tried unit testing your business layer?
adoma
adomaOP2y ago
No i haven't, pretty new to this 😛
Preda
Preda2y ago
You can t be that new if you re working with Composition + Agregation So
adoma
adomaOP2y ago
im not sure if there is a problem with the html ive written
Preda
Preda2y ago
Most probably with the back end Show your aspx page
adoma
adomaOP2y ago
i will show the exception
Preda
Preda2y ago
K
adoma
adomaOP2y ago
SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Scores_Games_GameId". The conflict occurred in database "Highscore", table "dbo.Games", column 'Id'. how i understand this is that the id for the game i choose is 1 and the gameId it's setting is 0
Preda
Preda2y ago
Can you show the database? Your dbo.games table
adoma
adomaOP2y ago
yea sure give me a sec
adoma
adomaOP2y ago
Preda
Preda2y ago
Can you provide a screenshot of all classes in your project?
adoma
adomaOP2y ago
adoma
adomaOP2y ago
adoma
adomaOP2y ago
this is the html form
Preda
Preda2y ago
All the way on the right side You have your project explorer
adoma
adomaOP2y ago
don't see it 😛
Preda
Preda2y ago
Can you show your full VS window?
adoma
adomaOP2y ago
misunderstood what u meant, mb
Preda
Preda2y ago
Oh fck I wasn t expeting this type of building the website
adoma
adomaOP2y ago
what u mean m8? hahaha
Preda
Preda2y ago
I never have worked this way
adoma
adomaOP2y ago
it's Asp.net core MVC
Kouhai
Kouhai2y ago
what problem are you facing? @adoma
adoma
adomaOP2y ago
Took me time but i fixed the issue. Thanks for the assistance tho 🙂
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server