Repository: DanWahlin/AspNetCorePostgreSQLDockerApp
Branch: master
Commit: bd6384d22bd1
Files: 75
Total size: 79.0 KB
Directory structure:
gitextract_pe7d7h_7/
├── .gitignore
├── AspNetCorePostgreSQLDockerApp/
│ ├── .docker/
│ │ └── wait-for-postgres.sh
│ ├── .dockerignore
│ ├── APIs/
│ │ └── CustomersServiceController.cs
│ ├── AspNetCorePostgreSQLDockerApp.csproj
│ ├── Client/
│ │ ├── .editorconfig
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── angular.json
│ │ ├── browserslist
│ │ ├── e2e/
│ │ │ ├── protractor.conf.js
│ │ │ ├── src/
│ │ │ │ ├── app.e2e-spec.ts
│ │ │ │ └── app.po.ts
│ │ │ └── tsconfig.e2e.json
│ │ ├── package.json
│ │ ├── src/
│ │ │ ├── app/
│ │ │ │ ├── app-routing.module.ts
│ │ │ │ ├── app.component.css
│ │ │ │ ├── app.component.html
│ │ │ │ ├── app.component.spec.ts
│ │ │ │ ├── app.component.ts
│ │ │ │ ├── app.module.ts
│ │ │ │ ├── core/
│ │ │ │ │ └── data.service.ts
│ │ │ │ ├── customers/
│ │ │ │ │ ├── customers.component.html
│ │ │ │ │ └── customers.component.ts
│ │ │ │ └── shared/
│ │ │ │ └── interfaces.ts
│ │ │ ├── assets/
│ │ │ │ └── .gitkeep
│ │ │ ├── environments/
│ │ │ │ ├── environment.prod.ts
│ │ │ │ └── environment.ts
│ │ │ ├── index.html
│ │ │ ├── karma.conf.js
│ │ │ ├── main.ts
│ │ │ ├── polyfills.ts
│ │ │ ├── styles.css
│ │ │ ├── test.ts
│ │ │ ├── tsconfig.app.json
│ │ │ ├── tsconfig.spec.json
│ │ │ └── tslint.json
│ │ ├── tsconfig.json
│ │ └── tslint.json
│ ├── Controllers/
│ │ ├── CustomersController.cs
│ │ └── HomeController.cs
│ ├── Models/
│ │ ├── Customer.cs
│ │ ├── DockerCommand.cs
│ │ ├── DockerCommandExample.cs
│ │ ├── Order.cs
│ │ └── State.cs
│ ├── Program.cs
│ ├── Properties/
│ │ └── launchSettings.json
│ ├── Repository/
│ │ ├── CustomersDbContext.cs
│ │ ├── CustomersDbSeeder.cs
│ │ ├── CustomersRepository.cs
│ │ ├── DockerCommandsDbContext.cs
│ │ ├── DockerCommandsDbSeeder.cs
│ │ ├── DockerCommandsRepository.cs
│ │ ├── ICustomersRepository.cs
│ │ └── IDockerCommandsRepository.cs
│ ├── Startup.cs
│ ├── Views/
│ │ ├── Customers/
│ │ │ └── Index.cshtml
│ │ ├── Home/
│ │ │ └── Index.cshtml
│ │ ├── Shared/
│ │ │ ├── Error.cshtml
│ │ │ ├── _Layout.cshtml
│ │ │ └── _ValidationScriptsPartial.cshtml
│ │ ├── _ViewImports.cshtml
│ │ └── _ViewStart.cshtml
│ ├── appsettings.json
│ ├── aspnetcore.dockerfile
│ ├── aspnetcore.prod.dockerfile
│ ├── docker-compose.azure.yml
│ ├── docker-compose.prod.yml
│ ├── docker-compose.yml
│ └── wwwroot/
│ ├── css/
│ │ └── site.css
│ ├── index2.html
│ └── web.config
├── AspNetCorePostgreSQLDockerApp.sln
└── README.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
#project.json files
project.json.old
dist
.vs
#remove generated files
**/wwwroot/app/**/*.js
**/wwwroot/app/**/*.map
#remove node_modules copied into wwwroot
**/wwwroot/lib
**/wwwroot/libs/*
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/
================================================
FILE: AspNetCorePostgreSQLDockerApp/.docker/wait-for-postgres.sh
================================================
#!/bin/bash
set -e
host="$1"
shift
cmd="$@"
until psql -h "$host" -U "postgres" -c '\l'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
>&2 echo "Postgres is up - executing command"
exec $cmd
#Can call from docker-compose.yml by adding the following to dependent service entrypoint: ./.docker/wait-for-postgres.sh postgres:5432
================================================
FILE: AspNetCorePostgreSQLDockerApp/.dockerignore
================================================
node_modules
*/node_modules
================================================
FILE: AspNetCorePostgreSQLDockerApp/APIs/CustomersServiceController.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using AspNetCorePostgreSQLDockerApp.Models;
using AspNetCorePostgreSQLDockerApp.Repository;
using Microsoft.AspNetCore.Http;
namespace AspNetCorePostgreSQLDockerApp.Apis
{
[Route("api/[controller]/customers")]
public class CustomersServiceController : Controller
{
ICustomersRepository _repo;
public CustomersServiceController(ICustomersRepository repo) {
_repo = repo;
}
// GET api/dataservice/customers
[HttpGet()]
[ProducesResponseType(typeof(List<Customer>), 200)]
[ProducesResponseType(typeof(List<Customer>), 404)]
public async Task<ActionResult> Customers()
{
var customers = await _repo.GetCustomersAsync();
if (customers == null) {
return NotFound();
}
return Ok(customers);
}
// GET api/dataservice/customers/5
[HttpGet("{id}", Name = "GetCustomersRoute")]
[ProducesResponseType(typeof(Customer), 200)]
[ProducesResponseType(typeof(Customer), 404)]
public async Task<ActionResult> Customers(int id)
{
var customer = await _repo.GetCustomerAsync(id);
if (customer == null) {
return NotFound();
}
return Ok(customer);
}
// POST api/customers
[HttpPost()]
[ProducesResponseType(typeof(Customer), 201)]
[ProducesResponseType(typeof(string), 400)]
public async Task<ActionResult> PostCustomer([FromBody]Customer customer)
{
if (!ModelState.IsValid) {
return BadRequest(this.ModelState);
}
var newCustomer = await _repo.InsertCustomerAsync(customer);
if (newCustomer == null) {
return BadRequest("Unable to insert customer");
}
return CreatedAtRoute("GetCustomersRoute", new { id = newCustomer.Id}, newCustomer);
}
// PUT api/dataservice/customers/5
[HttpPut("{id}")]
[ProducesResponseType(typeof(bool), 200)]
[ProducesResponseType(typeof(bool), 400)]
public async Task<ActionResult> PutCustomer(int id, [FromBody]Customer customer)
{
if (!ModelState.IsValid) {
return BadRequest(this.ModelState);
}
var status = await _repo.UpdateCustomerAsync(customer);
if (!status) {
return BadRequest("Unable to update customer");
}
return Ok(status);
}
// DELETE api/dataservice/customers/5
[HttpDelete("{id}")]
[ProducesResponseType(typeof(bool), 200)]
[ProducesResponseType(typeof(bool), 404)]
public async Task<ActionResult> DeleteCustomer(int id)
{
var status = await _repo.DeleteCustomerAsync(id);
if (!status) {
return NotFound();
}
return Ok(status);
}
[HttpGet("states")]
[ProducesResponseType(typeof(List<State>), 200)]
[ProducesResponseType(typeof(List<State>), 404)]
public async Task<ActionResult> States() {
var states = await _repo.GetStatesAsync();
if (states == null) {
return NotFound();
}
return Ok(states);
}
}
public static class HttpRequestExtensions
{
public static Uri ToUri(this HttpRequest request)
{
var hostComponents = request.Host.ToUriComponent().Split(':');
var builder = new UriBuilder
{
Scheme = request.Scheme,
Host = hostComponents[0],
Path = request.Path,
Query = request.QueryString.ToUriComponent()
};
if (hostComponents.Length == 2)
{
builder.Port = Convert.ToInt32(hostComponents[1]);
}
return builder.Uri;
}
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/AspNetCorePostgreSQLDockerApp.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.1.0" />
</ItemGroup>
</Project>
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/.editorconfig
================================================
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/.gitignore
================================================
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/README.md
================================================
# CustomersApp
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.0.4.
## Development server
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.
## Code scaffolding
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`.
## Build
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.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/angular.json
================================================
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"customers-app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"aot": true,
"outputPath": "../wwwroot/dist",
"deleteOutputPath": false,
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "customers-app:build"
},
"configurations": {
"production": {
"browserTarget": "customers-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "customers-app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"customers-app-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "customers-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "customers-app:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "customers-app"
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/browserslist
================================================
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/e2e/protractor.conf.js
================================================
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/e2e/src/app.e2e-spec.ts
================================================
import { AppPage } from './app.po';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to customers-app!');
});
});
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/e2e/src/app.po.ts
================================================
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('app-root h1')).getText();
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/e2e/tsconfig.e2e.json
================================================
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/package.json
================================================
{
"name": "customers-app",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.0.6",
"@angular/common": "~9.0.6",
"@angular/compiler": "~9.0.6",
"@angular/core": "~11.0.5",
"@angular/forms": "~9.0.6",
"@angular/platform-browser": "~9.0.6",
"@angular/platform-browser-dynamic": "~9.0.6",
"@angular/router": "~9.0.6",
"core-js": "^2.5.4",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.900.6",
"@angular/cli": "~9.0.6",
"@angular/compiler-cli": "~9.0.6",
"@angular/language-service": "~9.0.6",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~6.3.16",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.4",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.7.5"
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/app-routing.module.ts
================================================
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { CustomersComponent } from './customers/customers.component';
const routes: Routes = [
{ path: '', pathMatch:'full', redirectTo: '/customers' },
{ path: 'customers', component: CustomersComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/app.component.css
================================================
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/app.component.html
================================================
<router-outlet></router-outlet>
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/app.component.spec.ts
================================================
import { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'customers-app'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('customers-app');
});
it('should render title in a h1 tag', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to customers-app!');
});
});
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/app.component.ts
================================================
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'customers-app';
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/app.module.ts
================================================
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CustomersComponent } from './customers/customers.component';
@NgModule({
declarations: [
AppComponent, CustomersComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule, ReactiveFormsModule, HttpClientModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/core/data.service.ts
================================================
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
import { ICustomer } from '../shared/interfaces';
@Injectable({
providedIn: 'root'
})
export class DataService {
private url: string = 'api/customersservice/customers/';
constructor(private http: HttpClient) { }
getCustomersSummary() : Observable<ICustomer[]> {
return this.http.get<ICustomer[]>(this.url)
.pipe(
catchError(this.handleError)
);
}
updateCustomer(customer: ICustomer) {
return this.http.put(this.url + customer.id, customer)
.pipe(
catchError(this.handleError)
);
}
handleError(error: any) {
console.error(error);
return Observable.throw(error.json().error || 'Server error');
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/customers/customers.component.html
================================================
<h1>Customers</h1>
<br />
<!-- Added navbar to switch between list view shown in video and new edit view -->
<div class="navbar">
<ul class="nav navbar-nav">
<li class="toolbar-item">
<a (click)="editViewEnabled=false" [class.active]="!editViewEnabled">
<span class="glyphicon glyphicon-align-justify"></span> List View
</a>
</li>
<li class="toolbar-item">
<a (click)="editViewEnabled=true" [class.active]="editViewEnabled">
<span class="glyphicon glyphicon-pencil"></span> Edit View
</a>
</li>
</ul>
</div>
<div *ngIf="!editViewEnabled">
<div class="row header-row">
<div class="col-md-2">
Name
</div>
<div class="col-md-4">
Email
</div>
<div class="col-md-4">
Address
</div>
<div class="col-md-2">
City
</div>
</div>
<div class="row" *ngFor="let customer of customers">
<div class="col-md-2">
{{ customer.firstName }} {{ customer.lastName }}
</div>
<div class="col-md-4">
{{ customer.email }}
</div>
<div class="col-md-4">
{{ customer.address }}
</div>
<div class="col-md-2">
{{ customer.city }}
</div>
<br />
</div>
</div>
<!-- Added editable list to demonstrate doing an HTTP PUT -->
<div *ngIf="editViewEnabled">
<div class="container" *ngFor="let customer of customers">
<div class="row" *ngIf="editId !== customer.id">
<div class="col-md-4">
{{ customer.firstName }} {{ customer.lastName }}
</div>
<div class="col-md-8">
<span class="btn btn-success pull-left"
(click)="editId=customer.id">Edit</span>
</div>
</div>
<div *ngIf="editId == customer.id">
<h4>{{ customer.firstName }} {{ customer.lastName }}</h4>
<br />
<form (ngSubmit)="save(customer)" #customerForm="ngForm">
<div class="form-group">
<label for="name">First Name</label>
<input type="text" class="form-control" name="firstName" #firstName="ngModel" [(ngModel)]="customer.firstName" required>
<div class="alert alert-danger" [hidden]="firstName.valid">First Name is required</div>
</div>
<div class="form-group">
<label for="name">Last Name</label>
<input type="text" class="form-control" name="lastName" #lastName="ngModel" [(ngModel)]="customer.lastName" required>
<div class="alert alert-danger" [hidden]="lastName.valid">Last Name is required</div>
</div>
<div class="form-group">
<label for="name">Email</label>
<input type="text" class="form-control" name="email" #email="ngModel" [(ngModel)]="customer.email" required>
<div class="alert alert-danger" [hidden]="email.valid">Email is required</div>
</div>
<div class="form-group">
<label for="name">City</label>
<input type="text" class="form-control" name="city" #city="ngModel" [(ngModel)]="customer.city" required>
<div class="alert alert-danger" [hidden]="city.valid">City is required</div>
</div>
<div class="form-group">
<label for="name">Address</label>
<input type="text" class="form-control" name="address" #address="ngModel" [(ngModel)]="customer.address" required>
<div class="alert alert-danger" [hidden]="address.valid">Address is required</div>
</div>
<button type="submit" class="btn btn-success" [disabled]="!customerForm.valid">Submit</button>
<span type="button" class="btn btn-default" (click)="editId=0">Cancel</span>
</form>
</div>
<br />
</div>
<span class="alert alert-danger" [hidden]="!errorMessage">{{ errorMessage }}</span>
</div>
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/customers/customers.component.ts
================================================
import { Component, OnInit } from '@angular/core';
import { DataService } from '../core/data.service';
import { ICustomer } from '../shared/interfaces';
@Component({
selector: 'app-customers',
templateUrl: 'customers.component.html'
})
export class CustomersComponent implements OnInit {
customers: ICustomer[] = [];
editId: number = 0;
errorMessage: string;
editViewEnabled = false;
constructor(private dataService: DataService) { }
ngOnInit() {
this.dataService.getCustomersSummary()
.subscribe((data: ICustomer[]) => this.customers = data);
}
save(customer: ICustomer) {
this.dataService.updateCustomer(customer)
.subscribe((status: boolean) => {
if (status) {
this.editId = 0;
} else {
this.errorMessage = 'Unable to save customer';
}
})
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/shared/interfaces.ts
================================================
export interface ICustomer {
id: number;
firstName: string;
lastName: string;
email: string;
address: string;
city: string;
state: IState;
zip: number;
gender: string;
latitude: number;
longitude: number;
orderCount?: number;
orders?: IOrder[];
ordersTotal?: number;
}
export interface IState {
abbreviation: string;
name: string;
}
export interface IOrder {
product: string;
price: number;
quantity: number;
orderTotal?: number;
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/assets/.gitkeep
================================================
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/environments/environment.prod.ts
================================================
export const environment = {
production: true
};
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/environments/environment.ts
================================================
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/index.html
================================================
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CustomersApp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/karma.conf.js
================================================
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/main.ts
================================================
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/polyfills.ts
================================================
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags.ts';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/styles.css
================================================
/* You can add global styles to this file, and also import other style files */
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/test.ts
================================================
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/tsconfig.app.json
================================================
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"files": [
"main.ts",
"polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/tsconfig.spec.json
================================================
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/src/tslint.json
================================================
{
"extends": "../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
]
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/tsconfig.json
================================================
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"importHelpers": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Client/tslint.json
================================================
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"deprecation": {
"severity": "warn"
},
"eofline": true,
"forin": true,
"import-blacklist": [
true,
"rxjs/Rx"
],
"import-spacing": true,
"indent": [
true,
"spaces"
],
"interface-over-type-literal": true,
"label-position": true,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-misused-new": true,
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"prefer-const": true,
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"unified-signatures": true,
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"no-output-on-prefix": true,
"no-inputs-metadata-property": true,
"no-outputs-metadata-property": true,
"no-host-metadata-property": true,
"no-input-rename": true,
"no-output-rename": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Controllers/CustomersController.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace AspNetCorePostgreSQLDockerApp.Controllers
{
public class CustomersController : Controller
{
public ActionResult Index()
{
return View();
}
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Controllers/HomeController.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using AspNetCorePostgreSQLDockerApp.Repository;
namespace AspNetCorePostgreSQLDockerApp.Controllers
{
public class HomeController : Controller
{
IDockerCommandsRepository _repo;
public HomeController(IDockerCommandsRepository repo) {
_repo = repo;
}
public async Task<IActionResult> Index()
{
//Call into PostgreSQL
var commands = await _repo.GetDockerCommandsAsync();
return View(commands);
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
return View();
}
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
return View();
}
// public IActionResult Error()
// {
// return View();
// }
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Models/Customer.cs
================================================
using System.Collections.Generic;
namespace AspNetCorePostgreSQLDockerApp.Models {
public class Customer
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Address { get; set; }
public string City { get; set; }
public State State { get; set; }
public int Zip { get; set; }
public string Gender { get; set; }
public int OrderCount { get; set; }
public List<Order> Orders { get; set; }
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Models/DockerCommand.cs
================================================
using System;
using System.Collections.Generic;
namespace AspNetCorePostgreSQLDockerApp.Models {
public class DockerCommand {
public int Id { get; set; }
public string Command { get; set; }
public string Description { get; set; }
public List<DockerCommandExample> Examples { get; set; }
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Models/DockerCommandExample.cs
================================================
using System;
namespace AspNetCorePostgreSQLDockerApp.Models {
public class DockerCommandExample {
public int Id { get; set; }
public string Example { get; set; }
public string Description { get; set; }
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Models/Order.cs
================================================
namespace AspNetCorePostgreSQLDockerApp.Models {
public class Order {
public int Id { get; set; }
public string Product { get; set; }
public int Quantity { get; set; }
public decimal Price { get; set; }
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Models/State.cs
================================================
namespace AspNetCorePostgreSQLDockerApp.Models {
public class State {
public int Id { get; set; }
public string Abbreviation { get; set; }
public string Name { get; set; }
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Program.cs
================================================
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace AspNetCorePostgreSQLDockerApp
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Properties/launchSettings.json
================================================
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:50389/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"AspNetCorePostgreSQLDockerApp": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://0.0.0.0:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Repository/CustomersDbContext.cs
================================================
using Microsoft.EntityFrameworkCore;
using AspNetCorePostgreSQLDockerApp.Models;
namespace AspNetCorePostgreSQLDockerApp.Repository
{
public class CustomersDbContext : DbContext
{
public DbSet<Customer> Customers { get; set; }
public DbSet<Order> Orders { get; set; }
public DbSet<State> States { get; set; }
public CustomersDbContext (DbContextOptions<CustomersDbContext> options) : base(options) { }
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Repository/CustomersDbSeeder.cs
================================================
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using AspNetCorePostgreSQLDockerApp.Models;
namespace AspNetCorePostgreSQLDockerApp.Repository
{
public class CustomersDbSeeder
{
readonly ILogger _logger;
public CustomersDbSeeder(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger("CustomersDbSeederLogger");
}
public async Task SeedAsync(IServiceProvider serviceProvider)
{
//Based on EF team's example at https://github.com/aspnet/MusicStore/blob/dev/samples/MusicStore/Models/SampleData.cs
using (var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
var customersDb = serviceScope.ServiceProvider.GetService<CustomersDbContext>();
if (await customersDb.Database.EnsureCreatedAsync())
{
if (!await customersDb.Customers.AnyAsync()) {
await InsertCustomersSampleData(customersDb);
}
}
}
}
public async Task InsertCustomersSampleData(CustomersDbContext db)
{
var states = GetStates();
db.States.AddRange(states);
try
{
await db.SaveChangesAsync();
}
catch (Exception exp)
{
_logger.LogError($"Error in {nameof(CustomersDbSeeder)}: " + exp.Message);
throw;
}
var customers = GetCustomers(states);
db.Customers.AddRange(customers);
try
{
await db.SaveChangesAsync();
}
catch (Exception exp)
{
_logger.LogError($"Error in {nameof(CustomersDbSeeder)}: " + exp.Message);
throw;
}
}
private List<Customer> GetCustomers(List<State> states) {
//Customers
var customerNames = new string[]
{
"Marcus,HighTower,Male,acmecorp.com",
"Jesse,Smith,Female,gmail.com",
"Albert,Einstein,Male,outlook.com",
"Dan,Wahlin,Male,yahoo.com",
"Ward,Bell,Male,gmail.com",
"Brad,Green,Male,gmail.com",
"Igor,Minar,Male,gmail.com",
"Miško,Hevery,Male,gmail.com",
"Michelle,Avery,Female,acmecorp.com",
"Heedy,Wahlin,Female,hotmail.com",
"Thomas,Martin,Male,outlook.com",
"Jean,Martin,Female,outlook.com",
"Robin,Cleark,Female,acmecorp.com",
"Juan,Paulo,Male,yahoo.com",
"Gene,Thomas,Male,gmail.com",
"Pinal,Dave,Male,gmail.com",
"Fred,Roberts,Male,outlook.com",
"Tina,Roberts,Female,outlook.com",
"Cindy,Jamison,Female,gmail.com",
"Robyn,Flores,Female,yahoo.com",
"Jeff,Wahlin,Male,gmail.com",
"Danny,Wahlin,Male,gmail.com",
"Elaine,Jones,Female,yahoo.com",
"John,Papa,Male,gmail.com"
};
var addresses = new string[]
{
"1234 Anywhere St.",
"435 Main St.",
"1 Atomic St.",
"85 Cedar Dr.",
"12 Ocean View St.",
"1600 Amphitheatre Parkway",
"1604 Amphitheatre Parkway",
"1607 Amphitheatre Parkway",
"346 Cedar Ave.",
"4576 Main St.",
"964 Point St.",
"98756 Center St.",
"35632 Richmond Circle Apt B",
"2352 Angular Way",
"23566 Directive Pl.",
"235235 Yaz Blvd.",
"7656 Crescent St.",
"76543 Moon Ave.",
"84533 Hardrock St.",
"5687534 Jefferson Way",
"346346 Blue Pl.",
"23423 Adams St.",
"633 Main St.",
"899 Mickey Way"
};
var citiesStates = new string[]
{
"Phoenix,AZ,Arizona",
"Encinitas,CA,California",
"Seattle,WA,Washington",
"Chandler,AZ,Arizona",
"Dallas,TX,Texas",
"Orlando,FL,Florida",
"Carey,NC,North Carolina",
"Anaheim,CA,California",
"Dallas,TX,Texas",
"New York,NY,New York",
"White Plains,NY,New York",
"Las Vegas,NV,Nevada",
"Los Angeles,CA,California",
"Portland,OR,Oregon",
"Seattle,WA,Washington",
"Houston,TX,Texas",
"Chicago,IL,Illinois",
"Atlanta,GA,Georgia",
"Chandler,AZ,Arizona",
"Buffalo,NY,New York",
"Albuquerque,AZ,Arizona",
"Boise,ID,Idaho",
"Salt Lake City,UT,Utah",
"Orlando,FL,Florida"
};
var citiesIds = new int[] {5, 9, 44, 5, 36, 17, 16, 9, 36, 14, 14, 6, 9, 24, 44, 36, 25, 19, 5, 14, 5, 23, 38, 17};
var zip = 85229;
var orders = new List<Order>
{
new Order { Product = "Basket", Price = 29.99M, Quantity = 1 },
new Order { Product = "Yarn", Price = 9.99M, Quantity = 1 },
new Order { Product = "Needes", Price = 5.99M, Quantity = 1 },
new Order { Product = "Speakers", Price = 499.99M, Quantity = 1 },
new Order { Product = "iPod", Price = 399.99M, Quantity = 1 },
new Order { Product = "Table", Price = 329.99M, Quantity = 1 },
new Order { Product = "Chair", Price = 129.99M, Quantity = 4 },
new Order { Product = "Lamp", Price = 89.99M, Quantity = 5 },
new Order { Product = "Call of Duty", Price = 59.99M, Quantity = 1 },
new Order { Product = "Controller", Price = 49.99M, Quantity = 1 },
new Order { Product = "Gears of War", Price = 49.99M, Quantity = 1 },
new Order { Product = "Lego City", Price = 49.99M, Quantity = 1 },
new Order { Product = "Baseball", Price = 9.99M, Quantity = 5 },
new Order { Product = "Bat", Price = 19.99M, Quantity = 1 }
};
int firstOrder, lastOrder, tempOrder = 0;
var ordersLength = orders.Count;
var customers = new List<Customer>();
var random = new Random();
for (var i = 0; i < customerNames.Length; i++) {
var nameGenderHost = customerNames[i].Split(',');
var cityState = citiesStates[i].Split(',');
var state = states.Where(s => s.Abbreviation == cityState[1]).SingleOrDefault();
var customer = new Customer {
FirstName = nameGenderHost[0],
LastName = nameGenderHost[1],
Email = nameGenderHost[0] + '.' + nameGenderHost[1] + '@' + nameGenderHost[3],
Address = addresses[i],
City = cityState[0],
State = state,
Zip = zip + i,
Gender = nameGenderHost[2],
OrderCount = 0
};
firstOrder = (int)Math.Floor(random.NextDouble() * orders.Count);
lastOrder = (int)Math.Floor(random.NextDouble() * orders.Count);
if (firstOrder > lastOrder) {
tempOrder = firstOrder;
firstOrder = lastOrder;
lastOrder = tempOrder;
}
customer.Orders = new List<Order>();
for (var j = firstOrder; j <= lastOrder && j < ordersLength; j++) {
var order = new Order {
Product = orders[j].Product,
Price = orders[j].Price,
Quantity = orders[j].Quantity
};
customer.Orders.Add(order);
}
customer.OrderCount = customer.Orders.Count;
customers.Add(customer);
}
return customers;
}
private List<State> GetStates() {
var states = new List<State>
{
new State { Name = "Alabama", Abbreviation = "AL" },
new State { Name = "Montana", Abbreviation = "MT" },
new State { Name = "Alaska", Abbreviation = "AK" },
new State { Name = "Nebraska", Abbreviation = "NE" },
new State { Name = "Arizona", Abbreviation = "AZ" },
new State { Name = "Nevada", Abbreviation = "NV" },
new State { Name = "Arkansas", Abbreviation = "AR" },
new State { Name = "New Hampshire", Abbreviation = "NH" },
new State { Name = "California", Abbreviation = "CA" },
new State { Name = "New Jersey", Abbreviation = "NJ" },
new State { Name = "Colorado", Abbreviation = "CO" },
new State { Name = "New Mexico", Abbreviation = "NM" },
new State { Name = "Connecticut", Abbreviation = "CT" },
new State { Name = "New York", Abbreviation = "NY" },
new State { Name = "Delaware", Abbreviation = "DE" },
new State { Name = "North Carolina", Abbreviation = "NC" },
new State { Name = "Florida", Abbreviation = "FL" },
new State { Name = "North Dakota", Abbreviation = "ND" },
new State { Name = "Georgia", Abbreviation = "GA" },
new State { Name = "Ohio", Abbreviation = "OH" },
new State { Name = "Hawaii", Abbreviation = "HI" },
new State { Name = "Oklahoma", Abbreviation = "OK" },
new State { Name = "Idaho", Abbreviation = "ID" },
new State { Name = "Oregon", Abbreviation = "OR" },
new State { Name = "Illinois", Abbreviation = "IL" },
new State { Name = "Pennsylvania", Abbreviation = "PA" },
new State { Name = "Indiana", Abbreviation = "IN" },
new State { Name = "Rhode Island", Abbreviation = "RI" },
new State { Name = "Iowa", Abbreviation = "IA" },
new State { Name = "South Carolina", Abbreviation = "SC" },
new State { Name = "Kansas", Abbreviation = "KS" },
new State { Name = "South Dakota", Abbreviation = "SD" },
new State { Name = "Kentucky", Abbreviation = "KY" },
new State { Name = "Tennessee", Abbreviation = "TN" },
new State { Name = "Louisiana", Abbreviation = "LA" },
new State { Name = "Texas", Abbreviation = "TX" },
new State { Name = "Maine", Abbreviation = "ME" },
new State { Name = "Utah", Abbreviation = "UT" },
new State { Name = "Maryland", Abbreviation = "MD" },
new State { Name = "Vermont", Abbreviation = "VT" },
new State { Name = "Massachusetts", Abbreviation = "MA" },
new State { Name = "Virginia", Abbreviation = "VA" },
new State { Name = "Michigan", Abbreviation = "MI" },
new State { Name = "Washington", Abbreviation = "WA" },
new State { Name = "Minnesota", Abbreviation = "MN" },
new State { Name = "West Virginia", Abbreviation = "WV" },
new State { Name = "Mississippi", Abbreviation = "MS" },
new State { Name = "Wisconsin", Abbreviation = "WI" },
new State { Name = "Missouri", Abbreviation = "MO" },
new State { Name = "Wyoming", Abbreviation = "WY" }
};
return states;
}
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Repository/CustomersRepository.cs
================================================
using System;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using AspNetCorePostgreSQLDockerApp.Models;
namespace AspNetCorePostgreSQLDockerApp.Repository
{
public class CustomersRepository : ICustomersRepository
{
private readonly CustomersDbContext _context;
private readonly ILogger _logger;
public CustomersRepository(CustomersDbContext context, ILoggerFactory loggerFactory) {
_context = context;
_logger = loggerFactory.CreateLogger("CustomersRepository");
}
public async Task<List<Customer>> GetCustomersAsync()
{
return await _context.Customers.OrderBy(c => c.LastName).ToListAsync();
}
public async Task<Customer> GetCustomerAsync(int id)
{
return await _context.Customers.SingleOrDefaultAsync(c => c.Id == id);
}
public async Task<List<State>> GetStatesAsync()
{
return await _context.States.OrderBy(s => s.Abbreviation).ToListAsync();
}
public async Task<Customer> InsertCustomerAsync(Customer customer)
{
_context.Add(customer);
try
{
await _context.SaveChangesAsync();
}
catch (System.Exception exp)
{
_logger.LogError($"Error in {nameof(InsertCustomerAsync)}: " + exp.Message);
}
return customer;
}
public async Task<bool> UpdateCustomerAsync(Customer customer)
{
//Will update all properties of the Customer
_context.Customers.Attach(customer);
_context.Entry(customer).State = EntityState.Modified;
try
{
return (await _context.SaveChangesAsync() > 0 ? true : false);
}
catch (Exception exp)
{
_logger.LogError($"Error in {nameof(UpdateCustomerAsync)}: " + exp.Message);
}
return false;
}
public async Task<bool> DeleteCustomerAsync(int id)
{
//Extra hop to the database but keeps it nice and simple for this demo
var customer = await _context.Customers.SingleOrDefaultAsync(c => c.Id == id);
_context.Remove(customer);
try
{
return (await _context.SaveChangesAsync() > 0 ? true : false);
}
catch (System.Exception exp)
{
_logger.LogError($"Error in {nameof(DeleteCustomerAsync)}: " + exp.Message);
}
return false;
}
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Repository/DockerCommandsDbContext.cs
================================================
using Microsoft.EntityFrameworkCore;
using AspNetCorePostgreSQLDockerApp.Models;
namespace AspNetCorePostgreSQLDockerApp.Repository
{
public class DockerCommandsDbContext : DbContext
{
public DbSet<DockerCommand> DockerCommands { get; set; }
public DockerCommandsDbContext(DbContextOptions<DockerCommandsDbContext> options) : base(options) { }
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Repository/DockerCommandsDbSeeder.cs
================================================
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using AspNetCorePostgreSQLDockerApp.Models;
namespace AspNetCorePostgreSQLDockerApp.Repository
{
public class DockerCommandsDbSeeder
{
readonly ILogger _logger;
public DockerCommandsDbSeeder(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger("DockerCommandsDbSeederLogger");
}
public async Task SeedAsync(IServiceProvider serviceProvider)
{
//Based on EF team's example at https://github.com/aspnet/MusicStore/blob/dev/samples/MusicStore/Models/SampleData.cs
using (var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
var dockerDb = serviceScope.ServiceProvider.GetService<DockerCommandsDbContext>();
var customersDb = serviceScope.ServiceProvider.GetService<CustomersDbContext>();
if (await dockerDb.Database.EnsureCreatedAsync())
{
if (!await dockerDb.DockerCommands.AnyAsync()) {
await InsertDockerSampleData(dockerDb);
}
}
}
}
public async Task InsertDockerSampleData(DockerCommandsDbContext db)
{
var commands = GetDockerCommands();
db.DockerCommands.AddRange(commands);
try
{
await db.SaveChangesAsync();
}
catch (Exception exp)
{
_logger.LogError($"Error in {nameof(DockerCommandsDbSeeder)}: " + exp.Message);
}
}
private List<DockerCommand> GetDockerCommands()
{
var cmd1 = new DockerCommand {
Command = "run",
Description = "Runs a Docker container",
Examples = new List<DockerCommandExample> {
new DockerCommandExample {
Example = "docker run imageName",
Description = "Creates a running container from the image. Pulls it from Docker Hub if the image is not local"
},
new DockerCommandExample {
Example = "docker run -d -p 8080:3000 imageName",
Description = "Runs a container in 'daemon' mode with an external port of 8080 and a container port of 3000."
}
}
};
var cmd2 = new DockerCommand {
Command = "ps",
Description = "Lists containers",
Examples = new List<DockerCommandExample> {
new DockerCommandExample {
Example = "docker ps",
Description = "Lists all running containers"
},
new DockerCommandExample {
Example = "docker ps -a",
Description = "Lists all containers (even if they are not running)"
}
}
};
return new List<DockerCommand> { cmd1, cmd2 };
}
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Repository/DockerCommandsRepository.cs
================================================
using System;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using AspNetCorePostgreSQLDockerApp.Models;
namespace AspNetCorePostgreSQLDockerApp.Repository
{
public class DockerCommandsRepository : IDockerCommandsRepository
{
private readonly DockerCommandsDbContext _context;
private readonly ILogger _logger;
public DockerCommandsRepository(DockerCommandsDbContext context, ILoggerFactory loggerFactory) {
_context = context;
_logger = loggerFactory.CreateLogger("DockerCommandsRepository");
}
public async Task<List<DockerCommand>> GetDockerCommandsAsync() {
return await _context.DockerCommands.Include(dc => dc.Examples).ToListAsync();
}
public async Task InsertDockerCommandAsync(DockerCommand command) {
_context.DockerCommands.Add(command);
try {
await _context.SaveChangesAsync();
}
catch (Exception exp) {
_logger.LogError($"Error in {nameof(InsertDockerCommandAsync)}: " + exp.Message);
}
}
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Repository/ICustomersRepository.cs
================================================
using System.Collections.Generic;
using System.Threading.Tasks;
using AspNetCorePostgreSQLDockerApp.Models;
namespace AspNetCorePostgreSQLDockerApp.Repository
{
public interface ICustomersRepository
{
Task<List<Customer>> GetCustomersAsync();
Task<Customer> GetCustomerAsync(int id);
Task<Customer> InsertCustomerAsync(Customer customer);
Task<bool> UpdateCustomerAsync(Customer customer);
Task<bool> DeleteCustomerAsync(int id);
Task<List<State>> GetStatesAsync();
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Repository/IDockerCommandsRepository.cs
================================================
using System.Collections.Generic;
using System.Threading.Tasks;
using AspNetCorePostgreSQLDockerApp.Models;
namespace AspNetCorePostgreSQLDockerApp.Repository
{
public interface IDockerCommandsRepository
{
Task<List<DockerCommand>> GetDockerCommandsAsync();
Task InsertDockerCommandAsync(DockerCommand command);
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Startup.cs
================================================
using System;
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.FileProviders;
using Microsoft.AspNetCore.SpaServices.AngularCli;
using Microsoft.OpenApi.Models;
using AspNetCorePostgreSQLDockerApp.Repository;
namespace AspNetCorePostgreSQLDockerApp
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; set; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
//Add PostgreSQL support
services.AddEntityFrameworkNpgsql()
.AddDbContext<DockerCommandsDbContext>(options =>
options.UseNpgsql(Configuration["Data:DbContext:DockerCommandsConnectionString"]))
.AddDbContext<CustomersDbContext>(options =>
options.UseNpgsql(Configuration["Data:DbContext:CustomersConnectionString"]));
services.AddControllersWithViews();
// Add our PostgreSQL Repositories (scoped to each request)
services.AddScoped<IDockerCommandsRepository, DockerCommandsRepository>();
services.AddScoped<ICustomersRepository, CustomersRepository>();
//Transient: Created each time they're needed
services.AddTransient<DockerCommandsDbSeeder>();
services.AddTransient<CustomersDbSeeder>();
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "Application API",
Description = "Application Documentation",
Contact = new OpenApiContact { Name = "Author" },
License = new OpenApiLicense { Name = "MIT", Url = new Uri("https://en.wikipedia.org/wiki/MIT_License") }
});
// Add XML comment document by uncommenting the following
// var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "MyApi.xml");
// options.IncludeXmlComments(filePath);
});
services.AddCors(o => o.AddPolicy("AllowAllPolicy", options =>
{
options.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
}));
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "dist";
});
// services.AddRouting(options => options.LowercaseUrls = true);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
DockerCommandsDbSeeder dockerCommandsDbSeeder, CustomersDbSeeder customersDbSeeder)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseCors("AllowAllPolicy");
app.UseStaticFiles();
app.UseSpaStaticFiles();
// Enable middleware to serve generated Swagger as a JSON endpoint
app.UseSwagger();
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
// Visit http://localhost:5000/swagger
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller}/{action}/{id?}");
// Handle redirecting client-side routes to Customers/Index route
endpoints.MapFallbackToController("Index", "Customers");
});
customersDbSeeder.SeedAsync(app.ApplicationServices).Wait();
dockerCommandsDbSeeder.SeedAsync(app.ApplicationServices).Wait();
}
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Views/Customers/Index.cshtml
================================================
<main class="container">
<app-root>
Loading...
</app-root>
<br /><br />
</main>
<!-- Angular scripts -->
<script src="dist/runtime-es2015.js" type="module"></script>
<script src="dist/runtime-es5.js" nomodule defer></script>
<script src="dist/polyfills-es5.js" nomodule defer></script>
<script src="dist/polyfills-es2015.js" type="module"></script>
<script src="dist/styles-es2015.js" type="module"></script>
<script src="dist/styles-es5.js" nomodule defer></script>
<script src="dist/vendor-es2015.js" type="module"></script>
<script src="dist/vendor-es5.js" nomodule defer></script>
<script src="dist/main-es2015.js" type="module"></script>
<script src="dist/main-es5.js" nomodule defer></script>
================================================
FILE: AspNetCorePostgreSQLDockerApp/Views/Home/Index.cshtml
================================================
@model List<AspNetCorePostgreSQLDockerApp.Models.DockerCommand>
@{
ViewData["Title"] = "Home Page";
}
<h1>Docker Commands</h1>
From the <a href="https://www.pluralsight.com/courses/docker-web-development">Docker for Web Developers</a> course on Pluralsight.
<br />
<br />
@foreach (var dockerCommand in Model) {
<h2>@dockerCommand.Command Command</h2>
@dockerCommand.Description
<br />
@foreach (var commandExample in dockerCommand.Examples) {
<h3>@commandExample.Example</h3>
@commandExample.Description
<br />
}
<br />
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/Views/Shared/Error.cshtml
================================================
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
================================================
FILE: AspNetCorePostgreSQLDockerApp/Views/Shared/_Layout.cshtml
================================================
<!doctype html>
<html lang="">
<head>
<base href="/" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Asp.Net Core PostgreSQL Docker/Angular App</title>
<environment names="Development,Staging,Production">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
</environment>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a asp-controller="Home" asp-action="Index" class="navbar-brand">ASP.NET Core, PostgreSQL, Docker and Angular/TypeScript App</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a asp-controller="Home" asp-action="Index">Docker Commands</a></li>
<li><a href="/customers">Customers</a></li>
</ul>
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© 2020 - Wahlin Consulting</p>
</footer>
</div>
<environment names="Development,Staging,Production">
</environment>
@RenderSection("scripts", required: false)
</body>
</html>
================================================
FILE: AspNetCorePostgreSQLDockerApp/Views/Shared/_ValidationScriptsPartial.cshtml
================================================
<environment names="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
<environment names="Staging,Production">
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js"
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/mvc/5.2.3/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive">
</script>
</environment>
================================================
FILE: AspNetCorePostgreSQLDockerApp/Views/_ViewImports.cshtml
================================================
@using AspNetCorePostgreSQLDockerApp
@using AspNetCorePostgreSQLDockerApp.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
================================================
FILE: AspNetCorePostgreSQLDockerApp/Views/_ViewStart.cshtml
================================================
@{
Layout = "_Layout";
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/appsettings.json
================================================
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"Data": {
"DbContext": {
"LocalConnectionString": "User ID=<YourUserName>;Password=;Server=127.0.0.1;Port=5432;Database=<YourUserName>;Pooling=true;",
"ConnectionString": "User ID=postgres;Password=password;Server=postgres;Port=5432;Database=POSTGRES_USER;Integrated Security=true;Pooling=true;",
"DockerCommandsConnectionString": "User ID=postgres;Password=password;Server=postgres;Port=5432;Database=DockerCommands;Integrated Security=true;Pooling=true;",
"CustomersConnectionString": "User ID=postgres;Password=password;Server=postgres;Port=5432;Database=Customers;Integrated Security=true;Pooling=true;"
}
}
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/aspnetcore.dockerfile
================================================
FROM mcr.microsoft.com/dotnet/core/sdk
LABEL author="Dan Wahlin"
ENV ASPNETCORE_URLS=http://+:5000
WORKDIR /var/www/aspnetcoreapp
COPY . .
EXPOSE 5000
ENTRYPOINT ["/bin/bash", "-c", "dotnet restore && dotnet run"]
# Note that this is only for demo and is intended to keep things simple.
# A multi-stage dockerfile would normally be used here to build the .dll and use
# the mcr.microsoft.com/dotnet/core/aspnet image for the final image
# Legacy linking commands. While these work, they aren't the preferred way now.
# Instead, use networks (see the docker-compose.yml file for an example).
# docker build -f aspnetcore.dockerfile -t danwahlin/aspnetcore .
# docker run -d --name my-postgres -e POSTGRES_PASSWORD=password postgres
# docker run -d -p 5000:5000 --link my-postgres:postgres danwahlin/aspnetcore
================================================
FILE: AspNetCorePostgreSQLDockerApp/aspnetcore.prod.dockerfile
================================================
FROM mcr.microsoft.com/dotnet/core/sdk AS build
WORKDIR /var/www/aspnetcoreapp
# copy csproj and restore as distinct layers
COPY ./*.csproj ./
RUN dotnet restore
# copy everything else and build app
COPY ./ ./
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/core/aspnet
ENV ASPNETCORE_URLS=http://+:5000
WORKDIR /var/www/aspnetcoreapp
COPY --from=build /var/www/aspnetcoreapp/out ./
ENTRYPOINT ["dotnet", "AspNetCorePostgreSQLDockerApp.dll"]
================================================
FILE: AspNetCorePostgreSQLDockerApp/docker-compose.azure.yml
================================================
version: '3.7'
services:
web:
container_name: 'aspnetcoreapp'
# would need to tag aspnetcoreapp image as shown below to run
# used to setup a Web App for Containers example
# https://docs.microsoft.com/en-us/azure/app-service/containers/quickstart-multi-container
image: 'danwahlin/aspnetcoreapp'
ports:
- "80:5000"
depends_on:
- "postgres"
networks:
- aspnetcoreapp-network
postgres:
container_name: 'postgres'
image: postgres
environment:
# change this for a "real" app!
POSTGRES_PASSWORD: password
networks:
- aspnetcoreapp-network
networks:
aspnetcoreapp-network:
driver: bridge
================================================
FILE: AspNetCorePostgreSQLDockerApp/docker-compose.prod.yml
================================================
version: '3.7'
services:
web:
container_name: 'aspnetcoreapp'
image: 'aspnetcoreapp'
build:
context: .
dockerfile: aspnetcore.prod.dockerfile
ports:
- "5000:5000"
depends_on:
- "postgres"
networks:
- aspnetcoreapp-network
postgres:
container_name: 'postgres'
image: postgres
environment:
# change this for a "real" app!
POSTGRES_PASSWORD: password
networks:
- aspnetcoreapp-network
networks:
aspnetcoreapp-network:
driver: bridge
================================================
FILE: AspNetCorePostgreSQLDockerApp/docker-compose.yml
================================================
version: '3.7'
services:
web:
container_name: 'aspnetcoreapp'
image: 'aspnetcoreapp'
build:
context: .
dockerfile: aspnetcore.dockerfile
ports:
- "5000:5000"
depends_on:
- "postgres"
networks:
- aspnetcoreapp-network
postgres:
container_name: 'postgres'
image: postgres
environment:
# change this for a "real" app!
POSTGRES_PASSWORD: password
networks:
- aspnetcoreapp-network
networks:
aspnetcoreapp-network:
driver: bridge
================================================
FILE: AspNetCorePostgreSQLDockerApp/wwwroot/css/site.css
================================================
body {
padding-top: 50px;
padding-bottom: 20px;
}
/* Wrapping element */
/* Set some basic padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
.header-row {
background-color: #efefef;
}
.header-row div {
font-weight: bold;
margin: 10px 00px 10px 0px;
}
/* Set widths on the form inputs since otherwise they're 100% wide */
input,
select,
textarea,
.alert-danger {
max-width: 300px;
}
.toolbar-item a {
cursor: pointer;
}
input.ng-invalid, select.ng-invalid {
border-left: 5px solid #a94442;
}
input.ng-valid, select.ng-valid {
border-left: 5px solid #42A948;
}
================================================
FILE: AspNetCorePostgreSQLDockerApp/wwwroot/index2.html
================================================
<html>
<head>
<title>Angular and ASP.NET Core</title>
<base href="/" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="css/site.css">
</head>
<body>
<main class="container">
<app-root>
Loading...
</app-root>
<br /><br />
</main>
<script type="text/javascript" src="runtime.js"></script>
<script type="text/javascript" src="polyfills.js"></script>
<script type="text/javascript" src="styles.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
================================================
FILE: AspNetCorePostgreSQLDockerApp/wwwroot/web.config
================================================
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
</system.webServer>
</configuration>
================================================
FILE: AspNetCorePostgreSQLDockerApp.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspNetCorePostgreSQLDockerApp", "AspNetCorePostgreSQLDockerApp/AspNetCorePostgreSQLDockerApp.csproj", "{94FF9455-201B-452A-8262-AFB25D1CF615}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCorePostgreSQLDockerApp", "AspNetCorePostgreSQLDockerApp\AspNetCorePostgreSQLDockerApp.csproj", "{E32E1866-48E9-47FA-9DEF-3F91BC29C5C8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E32E1866-48E9-47FA-9DEF-3F91BC29C5C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E32E1866-48E9-47FA-9DEF-3F91BC29C5C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E32E1866-48E9-47FA-9DEF-3F91BC29C5C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E32E1866-48E9-47FA-9DEF-3F91BC29C5C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E32E1866-48E9-47FA-9DEF-3F91BC29C5C8} = {94FF9455-201B-452A-8262-AFB25D1CF615}
EndGlobalSection
EndGlobal
================================================
FILE: README.md
================================================
# ASP.NET Core with PostgreSQL and Docker Demo
Application demo designed to show how ASP.NET Core and PostgreSQL can be run in Docker containers. The app uses Entity Framework to create a simple database that stores Docker commands and examples. It also shows how Angular can be integrated with Web API to display customer information.
### Running the App with Docker Compose
1. Install `Docker Desktop for Mac` or `Docker Desktop for Windows`.
1. Navigate to the `AspNetCorePostgreSQLDockerApp` subfolder in a console window.
1. Open the `Client` folder in a terminal window and run the following commands at the root of the folder (requires Node.js):
- `npm install`
- `npm install -g @angular/cli`
- `ng build`
1. Move back up a level to the `AspNetCorePostgreSQLDockerApp` in the terminal window:
- Run `docker-compose build`
- Run `docker-compose up`
1. Navigate to http://localhost:5000 in your browser to view the site.
## Using the Web App for Container Services on Azure
1. Run `docker-compose -f docker-compose.prod.yml build`.
1. Tag the `aspnetcoreapp` image as `[yourDockerHubUserAccount]/aspnetcoreapp`. Make sure you substitute your Docker Hub user account for `[yourDockerHubUserAccount]`.
1. Push the image to Docker Hub using `docker push [yourDockerHubUserAccount]/aspnetcoreapp`.
1. Open `docker-compose azure.yml` file and change the image for the `web` service to `[yourDockerHubUserAccount]/aspnetcoreapp`.
1. Create a new `Web App for Containers` service in Azure. You'll need to add it to a new or existing Resource Group.
1. On the `Docker` tab, switch `Options` to `Docker Compose`, `Image Source` to `Docker Hub` and upload the `docker-compose azure.yml` file using the `Configuration File` section of the screen.
1. Wait for the service to start (it may take a few minutes to pull the image and fire up the Web App Service) and then click the web link it provides in the `Overview` section to hit the app.
gitextract_pe7d7h_7/ ├── .gitignore ├── AspNetCorePostgreSQLDockerApp/ │ ├── .docker/ │ │ └── wait-for-postgres.sh │ ├── .dockerignore │ ├── APIs/ │ │ └── CustomersServiceController.cs │ ├── AspNetCorePostgreSQLDockerApp.csproj │ ├── Client/ │ │ ├── .editorconfig │ │ ├── .gitignore │ │ ├── README.md │ │ ├── angular.json │ │ ├── browserslist │ │ ├── e2e/ │ │ │ ├── protractor.conf.js │ │ │ ├── src/ │ │ │ │ ├── app.e2e-spec.ts │ │ │ │ └── app.po.ts │ │ │ └── tsconfig.e2e.json │ │ ├── package.json │ │ ├── src/ │ │ │ ├── app/ │ │ │ │ ├── app-routing.module.ts │ │ │ │ ├── app.component.css │ │ │ │ ├── app.component.html │ │ │ │ ├── app.component.spec.ts │ │ │ │ ├── app.component.ts │ │ │ │ ├── app.module.ts │ │ │ │ ├── core/ │ │ │ │ │ └── data.service.ts │ │ │ │ ├── customers/ │ │ │ │ │ ├── customers.component.html │ │ │ │ │ └── customers.component.ts │ │ │ │ └── shared/ │ │ │ │ └── interfaces.ts │ │ │ ├── assets/ │ │ │ │ └── .gitkeep │ │ │ ├── environments/ │ │ │ │ ├── environment.prod.ts │ │ │ │ └── environment.ts │ │ │ ├── index.html │ │ │ ├── karma.conf.js │ │ │ ├── main.ts │ │ │ ├── polyfills.ts │ │ │ ├── styles.css │ │ │ ├── test.ts │ │ │ ├── tsconfig.app.json │ │ │ ├── tsconfig.spec.json │ │ │ └── tslint.json │ │ ├── tsconfig.json │ │ └── tslint.json │ ├── Controllers/ │ │ ├── CustomersController.cs │ │ └── HomeController.cs │ ├── Models/ │ │ ├── Customer.cs │ │ ├── DockerCommand.cs │ │ ├── DockerCommandExample.cs │ │ ├── Order.cs │ │ └── State.cs │ ├── Program.cs │ ├── Properties/ │ │ └── launchSettings.json │ ├── Repository/ │ │ ├── CustomersDbContext.cs │ │ ├── CustomersDbSeeder.cs │ │ ├── CustomersRepository.cs │ │ ├── DockerCommandsDbContext.cs │ │ ├── DockerCommandsDbSeeder.cs │ │ ├── DockerCommandsRepository.cs │ │ ├── ICustomersRepository.cs │ │ └── IDockerCommandsRepository.cs │ ├── Startup.cs │ ├── Views/ │ │ ├── Customers/ │ │ │ └── Index.cshtml │ │ ├── Home/ │ │ │ └── Index.cshtml │ │ ├── Shared/ │ │ │ ├── Error.cshtml │ │ │ ├── _Layout.cshtml │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml │ ├── appsettings.json │ ├── aspnetcore.dockerfile │ ├── aspnetcore.prod.dockerfile │ ├── docker-compose.azure.yml │ ├── docker-compose.prod.yml │ ├── docker-compose.yml │ └── wwwroot/ │ ├── css/ │ │ └── site.css │ ├── index2.html │ └── web.config ├── AspNetCorePostgreSQLDockerApp.sln └── README.md
SYMBOL INDEX (85 symbols across 26 files)
FILE: AspNetCorePostgreSQLDockerApp/APIs/CustomersServiceController.cs
class CustomersServiceController (line 12) | [Route("api/[controller]/customers")]
method CustomersServiceController (line 17) | public CustomersServiceController(ICustomersRepository repo) {
method Customers (line 22) | [HttpGet()]
method Customers (line 35) | [HttpGet("{id}", Name = "GetCustomersRoute")]
method PostCustomer (line 48) | [HttpPost()]
method PutCustomer (line 65) | [HttpPut("{id}")]
method DeleteCustomer (line 82) | [HttpDelete("{id}")]
method States (line 94) | [HttpGet("states")]
class HttpRequestExtensions (line 107) | public static class HttpRequestExtensions
method ToUri (line 109) | public static Uri ToUri(this HttpRequest request)
FILE: AspNetCorePostgreSQLDockerApp/Client/e2e/protractor.conf.js
method onPrepare (line 22) | onPrepare() {
FILE: AspNetCorePostgreSQLDockerApp/Client/e2e/src/app.po.ts
class AppPage (line 3) | class AppPage {
method navigateTo (line 4) | navigateTo() {
method getParagraphText (line 8) | getParagraphText() {
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/app-routing.module.ts
class AppRoutingModule (line 15) | class AppRoutingModule { }
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/app.component.ts
class AppComponent (line 8) | class AppComponent {
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/app.module.ts
class AppModule (line 23) | class AppModule { }
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/core/data.service.ts
class DataService (line 12) | class DataService {
method constructor (line 16) | constructor(private http: HttpClient) { }
method getCustomersSummary (line 18) | getCustomersSummary() : Observable<ICustomer[]> {
method updateCustomer (line 25) | updateCustomer(customer: ICustomer) {
method handleError (line 32) | handleError(error: any) {
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/customers/customers.component.ts
class CustomersComponent (line 10) | class CustomersComponent implements OnInit {
method constructor (line 17) | constructor(private dataService: DataService) { }
method ngOnInit (line 19) | ngOnInit() {
method save (line 24) | save(customer: ICustomer) {
FILE: AspNetCorePostgreSQLDockerApp/Client/src/app/shared/interfaces.ts
type ICustomer (line 1) | interface ICustomer {
type IState (line 18) | interface IState {
type IOrder (line 23) | interface IOrder {
FILE: AspNetCorePostgreSQLDockerApp/Controllers/CustomersController.cs
class CustomersController (line 9) | public class CustomersController : Controller
method Index (line 12) | public ActionResult Index()
FILE: AspNetCorePostgreSQLDockerApp/Controllers/HomeController.cs
class HomeController (line 11) | public class HomeController : Controller
method HomeController (line 16) | public HomeController(IDockerCommandsRepository repo) {
method Index (line 20) | public async Task<IActionResult> Index()
method About (line 27) | public IActionResult About()
method Contact (line 34) | public IActionResult Contact()
FILE: AspNetCorePostgreSQLDockerApp/Models/Customer.cs
class Customer (line 4) | public class Customer
FILE: AspNetCorePostgreSQLDockerApp/Models/DockerCommand.cs
class DockerCommand (line 6) | public class DockerCommand {
FILE: AspNetCorePostgreSQLDockerApp/Models/DockerCommandExample.cs
class DockerCommandExample (line 5) | public class DockerCommandExample {
FILE: AspNetCorePostgreSQLDockerApp/Models/Order.cs
class Order (line 2) | public class Order {
FILE: AspNetCorePostgreSQLDockerApp/Models/State.cs
class State (line 2) | public class State {
FILE: AspNetCorePostgreSQLDockerApp/Program.cs
class Program (line 7) | public class Program
method Main (line 9) | public static void Main(string[] args)
method CreateHostBuilder (line 14) | public static IHostBuilder CreateHostBuilder(string[] args) =>
FILE: AspNetCorePostgreSQLDockerApp/Repository/CustomersDbContext.cs
class CustomersDbContext (line 6) | public class CustomersDbContext : DbContext
method CustomersDbContext (line 12) | public CustomersDbContext (DbContextOptions<CustomersDbContext> option...
FILE: AspNetCorePostgreSQLDockerApp/Repository/CustomersDbSeeder.cs
class CustomersDbSeeder (line 12) | public class CustomersDbSeeder
method CustomersDbSeeder (line 16) | public CustomersDbSeeder(ILoggerFactory loggerFactory)
method SeedAsync (line 21) | public async Task SeedAsync(IServiceProvider serviceProvider)
method InsertCustomersSampleData (line 36) | public async Task InsertCustomersSampleData(CustomersDbContext db)
method GetCustomers (line 65) | private List<Customer> GetCustomers(List<State> states) {
method GetStates (line 219) | private List<State> GetStates() {
FILE: AspNetCorePostgreSQLDockerApp/Repository/CustomersRepository.cs
class CustomersRepository (line 12) | public class CustomersRepository : ICustomersRepository
method CustomersRepository (line 18) | public CustomersRepository(CustomersDbContext context, ILoggerFactory ...
method GetCustomersAsync (line 23) | public async Task<List<Customer>> GetCustomersAsync()
method GetCustomerAsync (line 28) | public async Task<Customer> GetCustomerAsync(int id)
method GetStatesAsync (line 33) | public async Task<List<State>> GetStatesAsync()
method InsertCustomerAsync (line 38) | public async Task<Customer> InsertCustomerAsync(Customer customer)
method UpdateCustomerAsync (line 53) | public async Task<bool> UpdateCustomerAsync(Customer customer)
method DeleteCustomerAsync (line 69) | public async Task<bool> DeleteCustomerAsync(int id)
FILE: AspNetCorePostgreSQLDockerApp/Repository/DockerCommandsDbContext.cs
class DockerCommandsDbContext (line 6) | public class DockerCommandsDbContext : DbContext
method DockerCommandsDbContext (line 10) | public DockerCommandsDbContext(DbContextOptions<DockerCommandsDbContex...
FILE: AspNetCorePostgreSQLDockerApp/Repository/DockerCommandsDbSeeder.cs
class DockerCommandsDbSeeder (line 12) | public class DockerCommandsDbSeeder
method DockerCommandsDbSeeder (line 16) | public DockerCommandsDbSeeder(ILoggerFactory loggerFactory)
method SeedAsync (line 21) | public async Task SeedAsync(IServiceProvider serviceProvider)
method InsertDockerSampleData (line 38) | public async Task InsertDockerSampleData(DockerCommandsDbContext db)
method GetDockerCommands (line 54) | private List<DockerCommand> GetDockerCommands()
FILE: AspNetCorePostgreSQLDockerApp/Repository/DockerCommandsRepository.cs
class DockerCommandsRepository (line 12) | public class DockerCommandsRepository : IDockerCommandsRepository
method DockerCommandsRepository (line 17) | public DockerCommandsRepository(DockerCommandsDbContext context, ILogg...
method GetDockerCommandsAsync (line 22) | public async Task<List<DockerCommand>> GetDockerCommandsAsync() {
method InsertDockerCommandAsync (line 26) | public async Task InsertDockerCommandAsync(DockerCommand command) {
FILE: AspNetCorePostgreSQLDockerApp/Repository/ICustomersRepository.cs
type ICustomersRepository (line 8) | public interface ICustomersRepository
method GetCustomersAsync (line 10) | Task<List<Customer>> GetCustomersAsync();
method GetCustomerAsync (line 12) | Task<Customer> GetCustomerAsync(int id);
method InsertCustomerAsync (line 14) | Task<Customer> InsertCustomerAsync(Customer customer);
method UpdateCustomerAsync (line 15) | Task<bool> UpdateCustomerAsync(Customer customer);
method DeleteCustomerAsync (line 16) | Task<bool> DeleteCustomerAsync(int id);
method GetStatesAsync (line 17) | Task<List<State>> GetStatesAsync();
FILE: AspNetCorePostgreSQLDockerApp/Repository/IDockerCommandsRepository.cs
type IDockerCommandsRepository (line 8) | public interface IDockerCommandsRepository
method GetDockerCommandsAsync (line 10) | Task<List<DockerCommand>> GetDockerCommandsAsync();
method InsertDockerCommandAsync (line 12) | Task InsertDockerCommandAsync(DockerCommand command);
FILE: AspNetCorePostgreSQLDockerApp/Startup.cs
class Startup (line 18) | public class Startup
method Startup (line 20) | public Startup(IConfiguration configuration)
method ConfigureServices (line 28) | public void ConfigureServices(IServiceCollection services)
method Configure (line 83) | public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
Condensed preview — 75 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (92K chars).
[
{
"path": ".gitignore",
"chars": 3850,
"preview": "#project.json files\nproject.json.old\n\ndist\n.vs\n\n#remove generated files\n**/wwwroot/app/**/*.js\n**/wwwroot/app/**/*.map\n\n"
},
{
"path": "AspNetCorePostgreSQLDockerApp/.docker/wait-for-postgres.sh",
"chars": 354,
"preview": "#!/bin/bash\n\nset -e\n\nhost=\"$1\"\nshift\ncmd=\"$@\"\n\nuntil psql -h \"$host\" -U \"postgres\" -c '\\l'; do\n >&2 echo \"Postgres is u"
},
{
"path": "AspNetCorePostgreSQLDockerApp/.dockerignore",
"chars": 27,
"preview": "node_modules\n*/node_modules"
},
{
"path": "AspNetCorePostgreSQLDockerApp/APIs/CustomersServiceController.cs",
"chars": 4068,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Microsoft.AspNetC"
},
{
"path": "AspNetCorePostgreSQLDockerApp/AspNetCorePostgreSQLDockerApp.csproj",
"chars": 443,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\r\n\r\n <PropertyGroup>\r\n <TargetFramework>netcoreapp3.1</TargetFramework>\r\n </P"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/.editorconfig",
"chars": 245,
"preview": "# Editor configuration, see http://editorconfig.org\nroot = true\n\n[*]\ncharset = utf-8\nindent_style = space\nindent_size = "
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/.gitignore",
"chars": 503,
"preview": "# See http://help.github.com/ignore-files/ for more about ignoring files.\n\n# compiled output\n/dist\n/tmp\n/out-tsc\n\n# depe"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/README.md",
"chars": 1029,
"preview": "# CustomersApp\n\nThis project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.0.4.\n\n##"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/angular.json",
"chars": 4018,
"preview": "{\n \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n \"version\": 1,\n \"newProjectRoot\": \"projects\",\n \""
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/browserslist",
"chars": 388,
"preview": "# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers\n# For additional inf"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/e2e/protractor.conf.js",
"chars": 752,
"preview": "// Protractor configuration file, see link for more information\n// https://github.com/angular/protractor/blob/master/lib"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/e2e/src/app.e2e-spec.ts",
"chars": 309,
"preview": "import { AppPage } from './app.po';\n\ndescribe('workspace-project App', () => {\n let page: AppPage;\n\n beforeEach(() => "
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/e2e/src/app.po.ts",
"chars": 208,
"preview": "import { browser, by, element } from 'protractor';\n\nexport class AppPage {\n navigateTo() {\n return browser.get('/');"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/e2e/tsconfig.e2e.json",
"chars": 213,
"preview": "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"../out-tsc/app\",\n \"module\": \"commonjs\",\n "
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/package.json",
"chars": 1317,
"preview": "{\n \"name\": \"customers-app\",\n \"version\": \"1.0.0\",\n \"scripts\": {\n \"ng\": \"ng\",\n \"start\": \"ng serve\",\n \"build\": "
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/app-routing.module.ts",
"chars": 437,
"preview": "import { NgModule } from '@angular/core';\nimport { Routes, RouterModule } from '@angular/router';\n\nimport { CustomersCom"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/app.component.css",
"chars": 0,
"preview": ""
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/app.component.html",
"chars": 32,
"preview": "<router-outlet></router-outlet>\n"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/app.component.spec.ts",
"chars": 1116,
"preview": "import { TestBed, async } from '@angular/core/testing';\nimport { RouterTestingModule } from '@angular/router/testing';\ni"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/app.component.ts",
"chars": 217,
"preview": "import { Component } from '@angular/core';\n\n@Component({\n selector: 'app-root',\n templateUrl: './app.component.html',\n"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/app.module.ts",
"chars": 696,
"preview": "import { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { FormsModul"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/core/data.service.ts",
"chars": 974,
"preview": "import { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\n\nimport { Observable } fr"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/customers/customers.component.html",
"chars": 4257,
"preview": "<h1>Customers</h1>\n<br />\n\n<!-- Added navbar to switch between list view shown in video and new edit view -->\n<div class"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/customers/customers.component.ts",
"chars": 946,
"preview": "import { Component, OnInit } from '@angular/core';\n\nimport { DataService } from '../core/data.service';\nimport { ICustom"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/app/shared/interfaces.ts",
"chars": 513,
"preview": "export interface ICustomer {\n id: number;\n firstName: string;\n lastName: string;\n email: string;\n address"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/assets/.gitkeep",
"chars": 0,
"preview": ""
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/environments/environment.prod.ts",
"chars": 51,
"preview": "export const environment = {\n production: true\n};\n"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/environments/environment.ts",
"chars": 662,
"preview": "// This file can be replaced during build by using the `fileReplacements` array.\n// `ng build --prod` replaces `environm"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/index.html",
"chars": 299,
"preview": "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <title>CustomersApp</title>\n <base href=\"/\">\n\n <met"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/karma.conf.js",
"chars": 964,
"preview": "// Karma configuration file, see link for more information\n// https://karma-runner.github.io/1.0/config/configuration-fi"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/main.ts",
"chars": 372,
"preview": "import { enableProdMode } from '@angular/core';\nimport { platformBrowserDynamic } from '@angular/platform-browser-dynami"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/polyfills.ts",
"chars": 2838,
"preview": "/**\n * This file includes polyfills needed by Angular and is loaded before the app.\n * You can add your own extra polyfi"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/styles.css",
"chars": 80,
"preview": "/* You can add global styles to this file, and also import other style files */\n"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/test.ts",
"chars": 642,
"preview": "// This file is required by karma.conf.js and loads recursively all the .spec and framework files\n\nimport 'zone.js/dist/"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/tsconfig.app.json",
"chars": 204,
"preview": "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"../out-tsc/app\",\n \"types\": []\n },\n \"files\""
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/tsconfig.spec.json",
"chars": 256,
"preview": "{\n \"extends\": \"../tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"../out-tsc/spec\",\n \"types\": [\n \"jasmine"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/src/tslint.json",
"chars": 314,
"preview": "{\n \"extends\": \"../tslint.json\",\n \"rules\": {\n \"directive-selector\": [\n true,\n \"attribu"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/tsconfig.json",
"chars": 470,
"preview": "{\n \"compileOnSave\": false,\n \"compilerOptions\": {\n \"baseUrl\": \"./\",\n \"downlevelIteration\": true,\n \"importHelpe"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Client/tslint.json",
"chars": 2832,
"preview": "{\n \"rulesDirectory\": [\n \"node_modules/codelyzer\"\n ],\n \"rules\": {\n \"arrow-return-shorthand\": true,\n \"callable"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Controllers/CustomersController.cs",
"chars": 332,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Microsoft.AspNetC"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Controllers/HomeController.cs",
"chars": 1083,
"preview": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Threading.Tasks;\r\nusing Microsoft.Asp"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Models/Customer.cs",
"chars": 540,
"preview": "using System.Collections.Generic;\n\nnamespace AspNetCorePostgreSQLDockerApp.Models {\n public class Customer\n {\n publ"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Models/DockerCommand.cs",
"chars": 321,
"preview": "using System;\nusing System.Collections.Generic;\n\nnamespace AspNetCorePostgreSQLDockerApp.Models {\n \n public class Dock"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Models/DockerCommandExample.cs",
"chars": 229,
"preview": "using System;\n\nnamespace AspNetCorePostgreSQLDockerApp.Models {\n \n public class DockerCommandExample {\n public int "
},
{
"path": "AspNetCorePostgreSQLDockerApp/Models/Order.cs",
"chars": 226,
"preview": "namespace AspNetCorePostgreSQLDockerApp.Models {\n public class Order {\n public int Id { get; set; }\n public strin"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Models/State.cs",
"chars": 191,
"preview": "namespace AspNetCorePostgreSQLDockerApp.Models {\n public class State {\n public int Id { get; set; }\n public strin"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Program.cs",
"chars": 583,
"preview": "using Microsoft.AspNetCore;\r\nusing Microsoft.AspNetCore.Hosting;\r\nusing Microsoft.Extensions.Hosting;\r\n\r\nnamespace AspNe"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Properties/launchSettings.json",
"chars": 658,
"preview": "{\r\n \"iisSettings\": {\r\n \"windowsAuthentication\": false,\r\n \"anonymousAuthentication\": true,\r\n \"iisExpress\": {\r\n "
},
{
"path": "AspNetCorePostgreSQLDockerApp/Repository/CustomersDbContext.cs",
"chars": 451,
"preview": "using Microsoft.EntityFrameworkCore;\nusing AspNetCorePostgreSQLDockerApp.Models;\n\nnamespace AspNetCorePostgreSQLDockerAp"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Repository/CustomersDbSeeder.cs",
"chars": 12348,
"preview": "using Microsoft.EntityFrameworkCore;\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Repository/CustomersRepository.cs",
"chars": 2725,
"preview": "using System;\nusing Microsoft.EntityFrameworkCore;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Thr"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Repository/DockerCommandsDbContext.cs",
"chars": 377,
"preview": "using Microsoft.EntityFrameworkCore;\nusing AspNetCorePostgreSQLDockerApp.Models;\n\nnamespace AspNetCorePostgreSQLDockerAp"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Repository/DockerCommandsDbSeeder.cs",
"chars": 3350,
"preview": "using Microsoft.EntityFrameworkCore;\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Repository/DockerCommandsRepository.cs",
"chars": 1199,
"preview": "using System;\nusing Microsoft.EntityFrameworkCore;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Thr"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Repository/ICustomersRepository.cs",
"chars": 546,
"preview": "using System.Collections.Generic;\nusing System.Threading.Tasks;\n\nusing AspNetCorePostgreSQLDockerApp.Models;\n\nnamespace "
},
{
"path": "AspNetCorePostgreSQLDockerApp/Repository/IDockerCommandsRepository.cs",
"chars": 359,
"preview": "using System.Collections.Generic;\nusing System.Threading.Tasks;\n\nusing AspNetCorePostgreSQLDockerApp.Models;\n\nnamespace "
},
{
"path": "AspNetCorePostgreSQLDockerApp/Startup.cs",
"chars": 4825,
"preview": "using System;\r\nusing System.IO;\r\nusing Microsoft.AspNetCore.Builder;\r\nusing Microsoft.AspNetCore.Hosting;\r\nusing Microso"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Views/Customers/Index.cshtml",
"chars": 721,
"preview": "<main class=\"container\">\n <app-root>\n Loading...\n </app-root>\n <br /><br />\n</main>\n\n<!-- Angular script"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Views/Home/Index.cshtml",
"chars": 602,
"preview": "@model List<AspNetCorePostgreSQLDockerApp.Models.DockerCommand>\r\n@{\r\n ViewData[\"Title\"] = \"Home Page\";\r\n}\r\n\r\n<h1>Dock"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Views/Shared/Error.cshtml",
"chars": 159,
"preview": "@{\r\n ViewData[\"Title\"] = \"Error\";\r\n}\r\n\r\n<h1 class=\"text-danger\">Error.</h1>\r\n<h2 class=\"text-danger\">An error occurre"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Views/Shared/_Layout.cshtml",
"chars": 2030,
"preview": "<!doctype html>\r\n<html lang=\"\">\r\n <head>\r\n <base href=\"/\" />\r\n <meta charset=\"utf-8\" />\r\n <meta "
},
{
"path": "AspNetCorePostgreSQLDockerApp/Views/Shared/_ValidationScriptsPartial.cshtml",
"chars": 881,
"preview": "<environment names=\"Development\">\r\n <script src=\"~/lib/jquery-validation/dist/jquery.validate.js\"></script>\r\n <scr"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Views/_ViewImports.cshtml",
"chars": 137,
"preview": "@using AspNetCorePostgreSQLDockerApp\r\n@using AspNetCorePostgreSQLDockerApp.Models\r\n@addTagHelper *, Microsoft.AspNetCore"
},
{
"path": "AspNetCorePostgreSQLDockerApp/Views/_ViewStart.cshtml",
"chars": 32,
"preview": "@{\r\n Layout = \"_Layout\";\r\n}\r\n"
},
{
"path": "AspNetCorePostgreSQLDockerApp/appsettings.json",
"chars": 818,
"preview": "{\n \"Logging\": {\n \"IncludeScopes\": false,\n \"LogLevel\": {\n \"Default\": \"Debug\",\n \"System\": \"Information\",\n"
},
{
"path": "AspNetCorePostgreSQLDockerApp/aspnetcore.dockerfile",
"chars": 818,
"preview": "FROM mcr.microsoft.com/dotnet/core/sdk\n\nLABEL author=\"Dan Wahlin\"\n\nENV ASPNETCORE_URLS=http://+:5000\n\nWORKDIR /var/www/a"
},
{
"path": "AspNetCorePostgreSQLDockerApp/aspnetcore.prod.dockerfile",
"chars": 467,
"preview": "FROM mcr.microsoft.com/dotnet/core/sdk AS build\nWORKDIR /var/www/aspnetcoreapp\n\n# copy csproj and restore as distinct la"
},
{
"path": "AspNetCorePostgreSQLDockerApp/docker-compose.azure.yml",
"chars": 679,
"preview": "version: '3.7'\n\nservices:\n\n web:\n container_name: 'aspnetcoreapp'\n # would need to tag aspnetcoreapp image as sho"
},
{
"path": "AspNetCorePostgreSQLDockerApp/docker-compose.prod.yml",
"chars": 530,
"preview": "version: '3.7'\n\nservices:\n\n web:\n container_name: 'aspnetcoreapp'\n image: 'aspnetcoreapp'\n build:\n contex"
},
{
"path": "AspNetCorePostgreSQLDockerApp/docker-compose.yml",
"chars": 525,
"preview": "version: '3.7'\n\nservices:\n\n web:\n container_name: 'aspnetcoreapp'\n image: 'aspnetcoreapp'\n build:\n contex"
},
{
"path": "AspNetCorePostgreSQLDockerApp/wwwroot/css/site.css",
"chars": 657,
"preview": "body {\n padding-top: 50px;\n padding-bottom: 20px;\n}\n\n/* Wrapping element */\n/* Set some basic padding to keep cont"
},
{
"path": "AspNetCorePostgreSQLDockerApp/wwwroot/index2.html",
"chars": 813,
"preview": "<html>\n <head>\n <title>Angular and ASP.NET Core</title>\n <base href=\"/\" />\n <meta charset=\"UTF-8\">\n <meta n"
},
{
"path": "AspNetCorePostgreSQLDockerApp/wwwroot/web.config",
"chars": 363,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n <system.webServer>\r\n <handlers>\r\n <add name=\"httpPlat"
},
{
"path": "AspNetCorePostgreSQLDockerApp.sln",
"chars": 1409,
"preview": "\r\nMicrosoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio 15\r\nVisualStudioVersion = 15.0.26228.9\r\n"
},
{
"path": "README.md",
"chars": 2000,
"preview": "# ASP.NET Core with PostgreSQL and Docker Demo\r\n\r\nApplication demo designed to show how ASP.NET Core and PostgreSQL can "
}
]
About this extraction
This page contains the full source code of the DanWahlin/AspNetCorePostgreSQLDockerApp GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 75 files (79.0 KB), approximately 21.7k tokens, and a symbol index with 85 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.