# IT-kariera Exam Template A template that could be useful for the final IT-kariera exam in 2021 ## Getting started Outside of having installed and configured ASP.NET and a database, all you need to do is: - Create an `appsettings.Develoment.json` file in `ExamTemplate/Web` that is a direct copy of `appsettings.json`, but you put in your connection string - Optional: Change the database the project uses (refer to [Database](#database)) The template is setup to automatically apply migrations and it comes by default with some. ## Structure This project uses some main layers. Those layers are the projects inside the solution. Their purpose is: - Common: Mainly constants and things that could be needed everywhere in the app - Data: Contains the project context, the context (database) models and migrations - Service: Contains the business logic, does stuff with the database - Web: the whole front-end - Views, View models and Controllers In some layers you have `Configurations` (Web and Service). Put your Automapper configurations there. The `css` files can be found in `ExamTemplate/Web/wwwroot/css/`. The main stuff are put in `styles.css` and that's where you probably should put your own stuff. ## Notes There are some configs that I've made that you may want to change. This section explains them. ### Database The project is made to use [PostgreSQL](https://www.postgresql.org/) by default. Since not everyone would want to use that, here are some steps for other databases. Using MySQL: 1. Install the [MySql.Data.EntityFrameworkCore](https://www.nuget.org/packages/MySql.Data.EntityFrameworkCore/) NuGet package in **both** `ExamTemplate/Web` and `ExamTemplate/Data` 2. In the `ConfigureServices` method, inside `ExamTemplate/Web/Startup.cs`, **and** in the `CreateDbContext` method, inside `ExamTemplate/Data/TemplateContextFactory.cs` change `UseNpgsql` to `UseMySQL` - You'll also need to add a using for the package in step 1 Using SQL Server (MSSQL): 1. Install the [Microsoft.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/) NuGet package in **both** `ExamTemplate/Web` and `ExamTemplate/Data` 2. In the `ConfigureServices` method, inside `ExamTemplate/Web/Startup.cs`, **and** in the `CreateDbContext` method, inside `ExamTemplate/Data/TemplateContextFactory.cs` change `UseNpgsql` to `UseSqlServer` - You'll also need to add a using for the package in step 1 ### HTTPS HTTPS is disabled by default, since certificates could cause issues on some systems. To revert: 1. Add `app.UseHttpsRedirection();` in the `Configure` method, inside `ExamTemplate/Web/Startup.cs` 2. Add `https://localhost:5001;` in `"applicationUrl"` in the `Web` section, inside `ExamTemplate/Web/Properties/launchSettings.json`. - So, line 21 in the `launchSettings.json` file should look like: `"applicationUrl": "https://localhost:5001;http://localhost:5000",`