├── .gitignore ├── LICENSE ├── README.md └── StartProject ├── UploadFilesClient ├── .browserslistrc ├── .editorconfig ├── .gitignore ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── README.md ├── angular.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src │ ├── app │ │ ├── _interfaces │ │ │ ├── user.model.ts │ │ │ └── userToCreate.model.ts │ │ ├── app.component.css │ │ ├── app.component.html │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ └── app.module.ts │ ├── assets │ │ └── .gitkeep │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── main.ts │ ├── polyfills.ts │ ├── styles.css │ └── test.ts ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json └── UploadFilesServer ├── .editorconfig ├── UploadFilesServer.sln └── UploadFilesServer ├── Context └── UserContext.cs ├── Controllers └── UsersController.cs ├── Migrations ├── 20220426123318_Initialize_DataBase.Designer.cs ├── 20220426123318_Initialize_DataBase.cs └── UserContextModelSnapshot.cs ├── Models └── User.cs ├── Program.cs ├── Properties └── launchSettings.json ├── UploadFilesServer.csproj ├── appsettings.Development.json └── appsettings.json /.gitignore: -------------------------------------------------------------------------------- 1 | /StartProject/UploadFilesServer/.vs 2 | /StartProject/UploadFilesServer/UploadFilesServer/bin 3 | /StartProject/UploadFilesServer/UploadFilesServer/obj 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Code Maze 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dotnet-core-file-upload Starter project 2 | ## https://code-maze.com/upload-files-dot-net-core-angular/ 3 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "pwa-chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "angular.enable-strict-mode-prompt": false 3 | } -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/README.md: -------------------------------------------------------------------------------- 1 | # UploadFilesClient 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.5. 4 | 5 | ## Development server 6 | 7 | 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. 8 | 9 | ## Code scaffolding 10 | 11 | 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`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "UploadFilesClient": { 7 | "projectType": "application", 8 | "schematics": {}, 9 | "root": "", 10 | "sourceRoot": "src", 11 | "prefix": "app", 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/upload-files-client", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "tsconfig.app.json", 21 | "assets": [ 22 | "src/favicon.ico", 23 | "src/assets" 24 | ], 25 | "styles": [ 26 | "src/styles.css", 27 | "node_modules/bootstrap/dist/css/bootstrap.min.css" 28 | ], 29 | "scripts": [] 30 | }, 31 | "configurations": { 32 | "production": { 33 | "budgets": [ 34 | { 35 | "type": "initial", 36 | "maximumWarning": "2mb", 37 | "maximumError": "5mb" 38 | }, 39 | { 40 | "type": "anyComponentStyle", 41 | "maximumWarning": "6kb", 42 | "maximumError": "10kb" 43 | } 44 | ], 45 | "fileReplacements": [ 46 | { 47 | "replace": "src/environments/environment.ts", 48 | "with": "src/environments/environment.prod.ts" 49 | } 50 | ], 51 | "outputHashing": "all" 52 | }, 53 | "development": { 54 | "buildOptimizer": false, 55 | "optimization": false, 56 | "vendorChunk": true, 57 | "extractLicenses": false, 58 | "sourceMap": true, 59 | "namedChunks": true 60 | } 61 | }, 62 | "defaultConfiguration": "production" 63 | }, 64 | "serve": { 65 | "builder": "@angular-devkit/build-angular:dev-server", 66 | "configurations": { 67 | "production": { 68 | "browserTarget": "UploadFilesClient:build:production" 69 | }, 70 | "development": { 71 | "browserTarget": "UploadFilesClient:build:development" 72 | } 73 | }, 74 | "defaultConfiguration": "development" 75 | }, 76 | "extract-i18n": { 77 | "builder": "@angular-devkit/build-angular:extract-i18n", 78 | "options": { 79 | "browserTarget": "UploadFilesClient:build" 80 | } 81 | }, 82 | "test": { 83 | "builder": "@angular-devkit/build-angular:karma", 84 | "options": { 85 | "main": "src/test.ts", 86 | "polyfills": "src/polyfills.ts", 87 | "tsConfig": "tsconfig.spec.json", 88 | "karmaConfig": "karma.conf.js", 89 | "assets": [ 90 | "src/favicon.ico", 91 | "src/assets" 92 | ], 93 | "styles": [ 94 | "src/styles.css" 95 | ], 96 | "scripts": [] 97 | } 98 | } 99 | } 100 | } 101 | }, 102 | "defaultProject": "UploadFilesClient" 103 | } 104 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/upload-files-client'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "upload-files-client", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "~13.2.0", 14 | "@angular/common": "~13.2.0", 15 | "@angular/compiler": "~13.2.0", 16 | "@angular/core": "~13.2.0", 17 | "@angular/forms": "~13.2.0", 18 | "@angular/platform-browser": "~13.2.0", 19 | "@angular/platform-browser-dynamic": "~13.2.0", 20 | "@angular/router": "~13.2.0", 21 | "bootstrap": "^5.1.3", 22 | "rxjs": "~7.5.0", 23 | "tslib": "^2.3.0", 24 | "zone.js": "~0.11.4" 25 | }, 26 | "devDependencies": { 27 | "@angular-devkit/build-angular": "~13.2.5", 28 | "@angular/cli": "~13.2.5", 29 | "@angular/compiler-cli": "~13.2.0", 30 | "@types/jasmine": "~3.10.0", 31 | "@types/node": "^12.11.1", 32 | "jasmine-core": "~4.0.0", 33 | "karma": "~6.3.0", 34 | "karma-chrome-launcher": "~3.1.0", 35 | "karma-coverage": "~2.1.0", 36 | "karma-jasmine": "~4.0.0", 37 | "karma-jasmine-html-reporter": "~1.7.0", 38 | "typescript": "~4.5.2" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/app/_interfaces/user.model.ts: -------------------------------------------------------------------------------- 1 | export interface User { 2 | id: string, 3 | name: string, 4 | address: string, 5 | imgPath: string 6 | } -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/app/_interfaces/userToCreate.model.ts: -------------------------------------------------------------------------------- 1 | export interface UserToCreate { 2 | name: string, 3 | address: string, 4 | imgPath: string 5 | } -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/app/app.component.css: -------------------------------------------------------------------------------- 1 | .create{ 2 | width: 700px; 3 | border: 1px solid rgb(206, 195, 195);; 4 | margin: 10px auto; 5 | padding: 10px; 6 | box-shadow: 1px 1px 1px gray; 7 | } 8 | 9 | article section h1{ 10 | text-align: center; 11 | } 12 | 13 | .users{ 14 | width: 900px; 15 | border: 1px solid rgb(206, 195, 195);; 16 | margin: 10px auto; 17 | padding: 10px; 18 | box-shadow: 1px 1px 1px gray; 19 | } -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Create User

4 |
5 |
6 | 7 | 9 |
10 |
11 | 12 | 14 |
15 |
16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
NameAddress
{{user.name}}{{user.address}}
38 |
39 |
40 | 41 |
42 |
43 |
44 |
-------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async () => { 6 | await TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | }); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'UploadFilesClient'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.componentInstance; 22 | expect(app.title).toEqual('UploadFilesClient'); 23 | }); 24 | 25 | it('should render title', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.nativeElement as HTMLElement; 29 | expect(compiled.querySelector('.content span')?.textContent).toContain('UploadFilesClient app is running!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { UserToCreate } from './_interfaces/userToCreate.model'; 2 | import { User } from './_interfaces/user.model'; 3 | import { Component, OnInit } from '@angular/core'; 4 | import { HttpClient, HttpErrorResponse } from '@angular/common/http'; 5 | 6 | @Component({ 7 | selector: 'app-root', 8 | templateUrl: './app.component.html', 9 | styleUrls: ['./app.component.css'] 10 | }) 11 | export class AppComponent implements OnInit { 12 | isCreate: boolean; 13 | name: string; 14 | address: string; 15 | user: UserToCreate; 16 | users: User[] = []; 17 | 18 | constructor(private http: HttpClient){} 19 | 20 | ngOnInit(){ 21 | this.isCreate = true; 22 | } 23 | 24 | onCreate = () => { 25 | this.user = { 26 | name: this.name, 27 | address: this.address, 28 | imgPath: '' 29 | } 30 | 31 | this.http.post('https://localhost:5001/api/users', this.user) 32 | .subscribe({ 33 | next: _ => { 34 | this.getUsers(); 35 | this.isCreate = false; 36 | }, 37 | error: (err: HttpErrorResponse) => console.log(err) 38 | }); 39 | } 40 | 41 | private getUsers = () => { 42 | this.http.get('https://localhost:5001/api/users') 43 | .subscribe({ 44 | next: (res) => this.users = res as User[], 45 | error: (err: HttpErrorResponse) => console.log(err) 46 | }); 47 | } 48 | 49 | returnToCreate = () => { 50 | this.isCreate = true; 51 | this.name = ''; 52 | this.address = ''; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { HttpClientModule } from '@angular/common/http' 5 | 6 | import { AppComponent } from './app.component'; 7 | 8 | @NgModule({ 9 | declarations: [ 10 | AppComponent 11 | ], 12 | imports: [ 13 | BrowserModule, 14 | FormsModule, 15 | HttpClientModule 16 | ], 17 | providers: [], 18 | bootstrap: [AppComponent] 19 | }) 20 | export class AppModule { } 21 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeMazeBlog/dotnet-core-file-upload/5c6f97c804fb09b985fdf40da783dff2e7abe8a1/StartProject/UploadFilesClient/src/assets/.gitkeep -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeMazeBlog/dotnet-core-file-upload/5c6f97c804fb09b985fdf40da783dff2e7abe8a1/StartProject/UploadFilesClient/src/favicon.ico -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UploadFilesClient 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes recent versions of Safari, Chrome (including 12 | * Opera), Edge on the desktop, and iOS and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * By default, zone.js will patch all possible macroTask and DomEvents 23 | * user can disable parts of macroTask/DomEvents patch by setting following flags 24 | * because those flags need to be set before `zone.js` being loaded, and webpack 25 | * will put import in the top of bundle, so user need to create a separate file 26 | * in this directory (for example: zone-flags.ts), and put the following flags 27 | * into that file, and then add the following code before importing zone.js. 28 | * import './zone-flags'; 29 | * 30 | * The flags allowed in zone-flags.ts are listed here. 31 | * 32 | * The following flags will work for all browsers. 33 | * 34 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 35 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 36 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 37 | * 38 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 39 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 40 | * 41 | * (window as any).__Zone_enable_cross_context_check = true; 42 | * 43 | */ 44 | 45 | /*************************************************************************************************** 46 | * Zone JS is required by default for Angular itself. 47 | */ 48 | import 'zone.js'; // Included with Angular CLI. 49 | 50 | 51 | /*************************************************************************************************** 52 | * APPLICATION IMPORTS 53 | */ 54 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | (id: string): T; 13 | keys(): string[]; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | ); 22 | 23 | // Then we find all the tests. 24 | const context = require.context('./', true, /\.spec\.ts$/); 25 | // And load the modules. 26 | context.keys().map(context); 27 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "sourceMap": true, 8 | "declaration": false, 9 | "downlevelIteration": true, 10 | "experimentalDecorators": true, 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2017", 14 | "module": "es2020", 15 | "lib": [ 16 | "es2020", 17 | "dom" 18 | ] 19 | }, 20 | "angularCompilerOptions": { 21 | "enableI18nLegacyMessageIdFormat": false 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /StartProject/UploadFilesClient/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # CS8604: Possible null reference argument. 4 | dotnet_diagnostic.CS8604.severity = silent 5 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32414.318 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UploadFilesServer", "UploadFilesServer\UploadFilesServer.csproj", "{F72BBF28-5FC8-4CF5-A3D4-A13652D2E35E}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D5BE507F-A18E-41FE-92C3-2BE5DBC59906}" 9 | ProjectSection(SolutionItems) = preProject 10 | .editorconfig = .editorconfig 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {F72BBF28-5FC8-4CF5-A3D4-A13652D2E35E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {F72BBF28-5FC8-4CF5-A3D4-A13652D2E35E}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {F72BBF28-5FC8-4CF5-A3D4-A13652D2E35E}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {F72BBF28-5FC8-4CF5-A3D4-A13652D2E35E}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | GlobalSection(ExtensibilityGlobals) = postSolution 28 | SolutionGuid = {B63CBE4C-A861-4437-82A9-8DE12296804B} 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/Context/UserContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using UploadFilesServer.Models; 3 | 4 | namespace UploadFilesServer.Context 5 | { 6 | public class UserContext: DbContext 7 | { 8 | public UserContext(DbContextOptions options) 9 | :base(options) 10 | { 11 | } 12 | 13 | public DbSet? Users { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/Controllers/UsersController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.EntityFrameworkCore; 4 | using UploadFilesServer.Context; 5 | using UploadFilesServer.Models; 6 | 7 | namespace UploadFilesServer.Controllers 8 | { 9 | [Route("api/[controller]")] 10 | [ApiController] 11 | public class UsersController : ControllerBase 12 | { 13 | private readonly UserContext _context; 14 | 15 | public UsersController(UserContext context) => _context = context; 16 | 17 | [HttpGet] 18 | public async Task GetAllUsers() 19 | { 20 | try 21 | { 22 | var users = await _context.Users.ToListAsync(); 23 | 24 | return Ok(users); 25 | } 26 | catch (Exception ex) 27 | { 28 | return StatusCode(500, $"Internal server error: {ex}"); 29 | } 30 | } 31 | 32 | [HttpPost] 33 | public async Task CreateUser([FromBody] User user) 34 | { 35 | try 36 | { 37 | if (user is null) 38 | { 39 | return BadRequest("User object is null"); 40 | } 41 | 42 | if (!ModelState.IsValid) 43 | { 44 | return BadRequest("Invalid model object"); 45 | } 46 | 47 | user.Id = Guid.NewGuid(); 48 | _context.Add(user); 49 | await _context.SaveChangesAsync(); 50 | 51 | return StatusCode(201); 52 | } 53 | catch (Exception ex) 54 | { 55 | return StatusCode(500, $"Internal server error: {ex}"); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/Migrations/20220426123318_Initialize_DataBase.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | using UploadFilesServer.Context; 9 | 10 | #nullable disable 11 | 12 | namespace UploadFilesServer.Migrations 13 | { 14 | [DbContext(typeof(UserContext))] 15 | [Migration("20220426123318_Initialize_DataBase")] 16 | partial class Initialize_DataBase 17 | { 18 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 19 | { 20 | #pragma warning disable 612, 618 21 | modelBuilder 22 | .HasAnnotation("ProductVersion", "6.0.4") 23 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 24 | 25 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); 26 | 27 | modelBuilder.Entity("UploadFilesServer.Models.User", b => 28 | { 29 | b.Property("Id") 30 | .ValueGeneratedOnAdd() 31 | .HasColumnType("uniqueidentifier"); 32 | 33 | b.Property("Address") 34 | .IsRequired() 35 | .HasColumnType("nvarchar(max)"); 36 | 37 | b.Property("ImgPath") 38 | .HasColumnType("nvarchar(max)"); 39 | 40 | b.Property("Name") 41 | .IsRequired() 42 | .HasColumnType("nvarchar(max)"); 43 | 44 | b.HasKey("Id"); 45 | 46 | b.ToTable("Users"); 47 | }); 48 | #pragma warning restore 612, 618 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/Migrations/20220426123318_Initialize_DataBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | #nullable disable 5 | 6 | namespace UploadFilesServer.Migrations 7 | { 8 | public partial class Initialize_DataBase : Migration 9 | { 10 | protected override void Up(MigrationBuilder migrationBuilder) 11 | { 12 | migrationBuilder.CreateTable( 13 | name: "Users", 14 | columns: table => new 15 | { 16 | Id = table.Column(type: "uniqueidentifier", nullable: false), 17 | Name = table.Column(type: "nvarchar(max)", nullable: false), 18 | Address = table.Column(type: "nvarchar(max)", nullable: false), 19 | ImgPath = table.Column(type: "nvarchar(max)", nullable: true) 20 | }, 21 | constraints: table => 22 | { 23 | table.PrimaryKey("PK_Users", x => x.Id); 24 | }); 25 | } 26 | 27 | protected override void Down(MigrationBuilder migrationBuilder) 28 | { 29 | migrationBuilder.DropTable( 30 | name: "Users"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/Migrations/UserContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 7 | using UploadFilesServer.Context; 8 | 9 | #nullable disable 10 | 11 | namespace UploadFilesServer.Migrations 12 | { 13 | [DbContext(typeof(UserContext))] 14 | partial class UserContextModelSnapshot : ModelSnapshot 15 | { 16 | protected override void BuildModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "6.0.4") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 22 | 23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); 24 | 25 | modelBuilder.Entity("UploadFilesServer.Models.User", b => 26 | { 27 | b.Property("Id") 28 | .ValueGeneratedOnAdd() 29 | .HasColumnType("uniqueidentifier"); 30 | 31 | b.Property("Address") 32 | .IsRequired() 33 | .HasColumnType("nvarchar(max)"); 34 | 35 | b.Property("ImgPath") 36 | .HasColumnType("nvarchar(max)"); 37 | 38 | b.Property("Name") 39 | .IsRequired() 40 | .HasColumnType("nvarchar(max)"); 41 | 42 | b.HasKey("Id"); 43 | 44 | b.ToTable("Users"); 45 | }); 46 | #pragma warning restore 612, 618 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/Models/User.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace UploadFilesServer.Models 4 | { 5 | public class User 6 | { 7 | [Key] 8 | public Guid Id { get; set; } 9 | 10 | [Required] 11 | public string? Name { get; set; } 12 | 13 | [Required] 14 | public string? Address { get; set; } 15 | 16 | public string? ImgPath { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using UploadFilesServer.Context; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | // Add services to the container. 7 | 8 | builder.Services.AddDbContext(opts => 9 | opts.UseSqlServer(builder.Configuration["sqlconnection:connectionString"])); 10 | 11 | builder.Services.AddCors(options => 12 | { 13 | options.AddPolicy("CorsPolicy", 14 | builder => builder.AllowAnyOrigin() 15 | .AllowAnyMethod() 16 | .AllowAnyHeader()); 17 | }); 18 | 19 | builder.Services.AddControllers(); 20 | 21 | var app = builder.Build(); 22 | 23 | // Configure the HTTP request pipeline. 24 | 25 | app.UseHttpsRedirection(); 26 | app.UseCors("CorsPolicy"); 27 | 28 | app.UseAuthorization(); 29 | 30 | app.MapControllers(); 31 | 32 | app.Run(); 33 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "UploadFilesServer": { 4 | "commandName": "Project", 5 | "dotnetRunMessages": true, 6 | "launchBrowser": false, 7 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 8 | "environmentVariables": { 9 | "ASPNETCORE_ENVIRONMENT": "Development" 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/UploadFilesServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /StartProject/UploadFilesServer/UploadFilesServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "sqlconnection": { 9 | "connectionString": "server=.; database=CodeMaze; Integrated Security=true" 10 | }, 11 | "AllowedHosts": "*" 12 | } 13 | --------------------------------------------------------------------------------