I'm taking my first foray into .NET and I'm designing a web app that's heavy on other web services right now. I'm intending to do the following:
- Take user input (a USDOT number)
- Request data from a public, government API on that DOT number (provided it is not available in local storage)
- Commit to DB (if needed)
- Pass to a risk score calculator which:
- Breaks apart the data and looks for red flags (like if the carrier has no authority) and other risks
- Passes the risk determination back to the view so the user can make an informed decision about the carrier.
The application will be questionnaire style and I'm going to rely on user input, but there's a few critical factors that can be generated immediately without any input. If these factors return something bad the user is probably going to stop there because they have what they need to make a decision on the carrier. So there will be an initial call / return on critical factors, then a more in-depth call / return that evaluates user response to questions.
I expect an integer risk score to be returned, so I can give the user a "high/medium/low risk" along with individual recommendations to help make an informed decision.
I found a great example app called AccountAtAGlance by Dan Wahlin (https://github.com/DanWahlin/AccountAtAGlance). I'm impressed by how much I retained from pluralsight and the books I am reading, because I understood most of his example app with ease.
I'm struggling with the best way to implement passing the data from the Carrier model into the Risk Score Calculator and the Risk Score Calculator passing it back to the Controller and I'm looking for help.
My file structure is basically mimicing the AccountAtAGlance example.
Right now my idea is as follows:
RiskScoreRepository.csavailable to the controller and have it call
- Here's where I get stuck:
GetCarrierRiskcalls something so it can evaluate the initial risk and return it to the controller.
So, a couple of questions I have:
Is a repository the appropriate place for
GetCarrierRisk go to get the data evaluated and returned? This is what I'm referring to as the Risk Score Calculator. Should it possibly be a
RiskScoreEngine? Similar to https://github.com/DanWahlin/AccountAtAGlance/blob/master/AccountAtAGlance.Repository/Helpers/StockEngine.cs?
I'm thinking it's better, for testability, to have each risk factor (like if the carrier has authority and if the carrier has inspections) to have its own method that accepts a raw value and returns the appropriate risk. But then how does the request flow into these methods? Does
GetCarrierRisk make a bunch of calls to the Risk Score Calculator and put the return into something like a List that gets passed to the controller?