diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-05-11 13:55:11 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-05-11 13:55:11 +0300 |
| commit | 7534ba1bd08cb84f8df32d7c64f6de40257eb8f0 (patch) | |
| tree | 5ea4e55559ff82ed8cc902539078d7c6997062ca | |
| parent | 6e72e69cfbef65c05005c793e0928b4d81224234 (diff) | |
| download | it-kariera-exam-template-7534ba1bd08cb84f8df32d7c64f6de40257eb8f0.tar it-kariera-exam-template-7534ba1bd08cb84f8df32d7c64f6de40257eb8f0.tar.gz it-kariera-exam-template-7534ba1bd08cb84f8df32d7c64f6de40257eb8f0.zip | |
Added information about the bash tools and cloudinary
| -rw-r--r-- | README.md | 80 |
1 files changed, 80 insertions, 0 deletions
@@ -22,6 +22,77 @@ In some layers you have `Configurations` (Web and Service). Put your Automapper 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. +## Tools + +The template comes with some very useful tools, found inside `ExamTemplate/tools/`. They are all Bash scripts, so to run them: +- Windows users could just use [git bash](https://gitforwindows.org/). Open a window inside the `ExamTemplate/tools/` folder, type in `./tool-name.sh` and then your parameters (so a command should be something like `./rename-project.sh CarShop`). +- Linux and MacOS users could just use their terminal. **But**, beware: the scripts aren't POSIX compatible, so you might have issues trying to run them. + +**No matter the OS, test out the scripts before the exam!** Also, **run these scripts ONLY from inside the `tools` folder!** Otherwise, a lot of stuff will break. + +The following sections explain the usage if these scripts. + +### rename-project + +As the title suggest, with this tool you could rename the whole project. It renames all of the files, folders and text inside files (so usings, namespaces, class names, variable names, etc.) that have the default name (`ExamTemplate`) , or a given name, to another given name. + +Example: renaming the default (`ExamTemplate`) to `CarShop` +```bash +./rename-project.sh CarShop +``` + +If you've already renamed your project and want to change the name yet again, just give the script two paramters: the first one is the current name and the second - the new name. + +Example: renaming the project called `CarShop` to `BookShop` +```bash +./rename-project.sh CarShop BookShop +``` + +You could rename stuff manually, but this and all other scripts rely on the naming structure that this script provides. + +### add-feature-template + +This is a scaffolding-like script. With it, you type in some information about the project and your desired feature and it generates most files you'll need in all layers (Data, service, Web). + +The script is meant to give you the inital stuff you'll need. Outside of some created files and their **preset contents** (simple default implementations), the script can't do anything else. Another limitation is references: it can't detect and add `using` statements, so if you use some fancy data type, make sure to add the appropriate `using`! + + **Example**: Let's say you [renamed](#rename-project) your project to `CarShop` and need a Car class that has a Brand, Model and Year. +- The first argument is the project name, then the name of your desired feature (should be the same name you would use when creating a database model) and then the different properties in the format `"type Name"`. +```bash +./add-feature-template.sh CarShop Car "string Brand" "string Model" "int Year" +``` +The script will create (and edit where specified) the following files: +``` +├─ Data +│ ├─ Models +│ │ └─ Car.cs +│ └─ CarShopContext.cs (Only edited; Adds a DbSet<Car>) +├─ Services +│ ├─ Configurations +│ │ └─ ServiceCarMappings.cs +│ ├─ Models +│ │ └─ Car +│ │ ├─ CarServiceModel.cs +│ │ ├─ CreateCarServiceModel.cs +│ │ └─ EditCarServiceModel.cs +│ └─ CarService.cs +├─ Web +│ ├─ Configurations +│ │ └─ ControllerCarMappings.cs +│ ├─ Controllers +│ │ └─ CarControllers.cs +│ └─ Views +│ ├─ Car +│ │ ├─ CarViewModel.cs +│ │ ├─ CreateCarViewModel.cs +│ │ └─ EditCarViewModel.cs +│ └─ _ViewImports.cshtml (Only edited; Adds reference to the Car View Models namespace) +└─ Startup.cs (Only edited; Adds dependency injection configuration for CarService) +``` +All of the models have all given properites **and a "Guid Id" property**. Only the Create models don't have the "Guid Id" property. + +Controller and Service have **very basic** CRUD of the model. No view links are added, so you'll need to provide them (and to test out if everything work: just edit the link in the browser). + ## Notes There are some configs that I've made that you may want to change. This section explains them. @@ -40,6 +111,15 @@ Using SQL Server (MSSQL): 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 +### Cloud + +The template uses [Cloudinary](https://cloudinary.com/) for source control. The logic for uploading a file is inside `ExamTemplate/Services/CloudinaryService.cs`. + +If you need cloud somewhere, just dependency-inject the service and update your `ExamTemplate/Web/appsettings.Development.json` with the values from your own Cloudinary account. + +Usage is simple: just call the `UploadFilesToCloud` method, and give it a `List<IFormFile>` (if you only need to upload one file, create a List and inside it put that file). It will return a List with the URLs of all given files. + +This does mean that your view models (that require uploading a file) will need an `IFormFile` property. In the HTML, your file upload form should have a `<input type="file">`. ### HTTPS |
