This is a simple application which calculates monthly premium for given inputs
As a Member user would like to have an ability to choose various options on the screen So that they can View the monthly premiums calculated and displayed on the screen
Develop an UI which accepts the below data and return a monthly premium amount to be calculated.
- Name
- Age
- Date of Birth
- Occupation
- Death – Sum Insured.
Following assumptions are taken while implementing:
- For any given individual the monthly premium is calculated using the below formula Death Premium = (Death Cover amount * Occupation Rating Factor * Age) / (1000 * 12)
- All input fields are mandatory.
- Given all the input fields are specified, change in the occupation dropdown should trigger the premium calculation
The three tier architecture is used when an effective distributed client/server design is needed that provides (when compared to the two tier) increased performance, flexibility, maintainability, reusability, and scalability, while hiding the complexity of distributed processing from the user.
The Core crux of the architecture is the 3 layers i.e. the UI layer for the View part, Business Logic layers to incorporate the business logic and the Data Access layer to access and provide the data from DB.
The Ui application always interacts only with the Business logic layer which in in turn interacts with Data access layer.
There are different projects in the solution as follows:
- WebAPI project
- DAL layer - Data Access Layer
- Business Logic Layer
- FrontendUI project with Angular 11
- WebAPI Unit Tests project
- WebAPI Integration Tests Project
- This has been implemented with Microsoft WebApi2
- Used SQL Server database file to hold the data
- Created two tables with data namely Occupation and Occupation Factor with the relevant keys
- Create Entity model with entity framework
- Used dependency injection with Autofac package
- Implemented exception handling for the controller methods
- Implemented Async programming for the methods
- Implemented Error logging with package Log4Net.
- Create Entity model with entity framework
- Used LINQ queries to return data
- Used interfaces
- Used intefaces
- Created business logic method to calculate premium value with given parameters
- Written test cases for the two endpoints created in the Web API which tests the entire flow from api to the DAL
- Written test cases for the two endpoints created in the Web API
- Testcases has been written using Moq mocking framework.
Check out the code and build the WebAPI solution and run the WebAPI first. Please hit the below URL to check if the WebAPI is running successfully http://localhost:49978/api/MonthlyPremium/GetOccupations
This project was generated with the latest version of Angular CLIAngular CLI.
This folder is placed in the same application path with the name PremiumCalculatorUI. Please go to this path and run the angular application by following the below steps. Ideally you can run this with Visual Studio Code and typing the command 'npm start' in the terminal
- Used bootstrap for the application
- Implemented validations for the input fields (All fields are mandatory)
- Monthly premium will be generated on change of Occupation dropdown and when all the fields are entered.
Run npm install
to install all node packages required by the application
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run ng test
to execute the unit tests via Karma.
Have implemented unit test cases for all the component and services with a code coverage of 75%
To get the code coverage lcov report use the command ng test --no-watch --code-coverage
Run ng e2e
to execute the end-to-end tests via Protractor.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.