Unable to calculate/store correct value to the db
Hello. I am developing a mortgage tracker for myself and currently trying to calculate my daily interest in my service controller. I am capturing my current interest rate and outstanding balance using the front end form, then the idea is to retrieve this value from the database in my service, calculate my actual daily interest rate and store it back into the db in my main interest rate controller. When I open my SQL explorer the value is unfortunately stored as 0.0000 decimal value and I can't debug it for the world at the moment as to why?
This is the service controller:
3 Replies
And my main controller below that stores the calculated value back into db:
Does
CalculateDailyInterestRate
method return what you'd expect it to return?it does I think, but realised in the mean time I am being completely dumb as usual. I haven't invoked the method anywhere or on any action, so I decided to call the method when I hit the submit button on the form. The idea is that it saves the form data to the db and then invokes the method to perform calculation on it but now I am getting a completely new unhandled exception which I don't understand at the moment, but working on it:
this is my main controller code for submitting the form now:
It seems the current issue might be that I am injecting controller with my method into another controller, instead of having a service for this?
Edit: I haven't registered my service in Program.cs file, all good now! 🙂