Can't withdraw and save new balance to database
Hey can someone help me with my issues I've been stuck on for hours? I am trying to make a withdraw from an account and from there update its new balance to the database. But every time I click withdraw I get 0 on the new balance and the database is not updating. Can someone look into my code and see if you can find the problem? Look into the Withdraw and AccountManagement. Thats were my issuses are.
https://github.com/agaquit/WebBankApplication
GitHub
GitHub - agaquit/WebBankApplication
Contribute to agaquit/WebBankApplication development by creating an account on GitHub.
5 Replies
?
You have an empty context.
Oh you have two database contexts.
Ye, the one database I am trying to update is the BankApplicationData that I scaffolded
Your code structure makes this project very annoying to navigate btw
have you tried just setting breakpoints and stepping through the withdrawal flow?
this has... issues
if there isnt enough money, you set a model error, then proceed to reduce the balance anyway :p
also, you are using EF Core wrong
why are these not async btw
thats a huge problem on its own
but even ignoring that, when you fetch an object from EF, EF "tracks" that object
WHy multiple contexts tho
edits to that object will be saved to database when next you call
SaveChangesAsync
without having to call Update
you even have a Withdraw
method in your account service, but opt to not use it
something about scaffold vs code first
this project is in general in very poor shape