├── .docker ├── .dockerignore ├── .gitkeep ├── docker-compose.override.yml └── docker-compose.yml ├── .gitignore ├── .infrastructure ├── .gitkeep └── sql.data │ ├── Dockerfile │ └── scripts │ ├── authentication.batch.sql │ ├── business.customers.batch.sql │ ├── history.batch.sql │ └── shoppingcart.batch.sql ├── .k8s └── .gitkeep ├── .scripts ├── .gitkeep ├── new-project.ps1 ├── start-rebuild.bat ├── start.sh ├── stop.sh └── stopAll.bat └── .tools └── .gitkeep /.docker/.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | **/.env.dev 25 | **/.env.stable 26 | **/.env.prod 27 | LICENSE 28 | README.md -------------------------------------------------------------------------------- /.docker/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javaniecampbell/demo/ebecdb78528aad6f6de5358803aa2768c16f9f71/.docker/.gitkeep -------------------------------------------------------------------------------- /.docker/docker-compose.override.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | # customer-portal-api-gateway: 5 | # restart: ${SERVICERESTARTBEHAVIOUR} 6 | # environment: 7 | # - ASPNETCORE_ENVIRONMENT=Development 8 | # - ASPNETCORE_URLS=https://+:443;http://+:80 9 | # - ASPNETCORE_HTTPS_PORT=44357 10 | # ports: 11 | # - "20044:80" 12 | # - "44357:443" 13 | # volumes: 14 | # - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro 15 | # - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro 16 | 17 | authentication-service: 18 | restart: ${SERVICERESTARTBEHAVIOUR} 19 | environment: 20 | - ASPNETCORE_ENVIRONMENT=Development 21 | # - ASPNETCORE_URLS=https://+:443;http://+:80 22 | - ASPNETCORE_URLS=http://+:80 23 | # - ASPNETCORE_HTTPS_PORT=44358 24 | - ConnectionStrings__DefaultConnection=Server=sql.data,1433;Database=OnboardingAuthDB;User Id=${SQLDATABASEUSER};Password=${SQLDATABASEPASSWORD}; 25 | - amqp__hostName=${AMQPHOST} 26 | - amqp__exchange=test.exchange 27 | - amqp__queueName=test.queue 28 | - amqp__routingKey=test 29 | - spring__application__name=authentication-service 30 | - eureka__client__serviceUrl=${SERVICEREGISTRYURL} 31 | - eureka__client__shouldFetchRegistry=${CLIENTSHOULDFETCHREGISTRY} 32 | - eureka__client__shouldRegisterWithEureka=${CLIENTSHOULDREGISTERWITHEUREKA} 33 | - eureka__instance__port=20045 34 | - tokenManagement__secret=${TOKENSECRET} 35 | - tokenManagement__issuer=${TOKENISSUER} 36 | - tokenManagement__audience=${TOKENAUDIENCE} 37 | - tokenManagement__accessExpiration=${TOKENACCESSEXPIRATION} 38 | - tokenManagement__refreshExpiration=${TOKENREFRESHEXPIRATION} 39 | # volumes: 40 | # - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro 41 | # - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro 42 | build: 43 | args: 44 | - CUSTOM_FEED_USERNAME=${PACKAGEFEEDUSER} 45 | - CUSTOM_FEED_PERSONAL_ACCESS_TOKEN=${PACKAGEPERSONALACCESSTOEKN} 46 | ports: 47 | - "20045:80" 48 | # - "44358:443" 49 | 50 | csv-service: 51 | restart: ${SERVICERESTARTBEHAVIOUR} 52 | environment: 53 | - ASPNETCORE_ENVIRONMENT=Development 54 | # - ASPNETCORE_URLS=https://+:443;http://+:80 55 | - ASPNETCORE_URLS=http://+:80 56 | # - ASPNETCORE_HTTPS_PORT=44360 57 | - amqp__hostName=${AMQPHOST} 58 | - amqp__exchange=test.exchange 59 | - amqp__queueName=test.queue 60 | - amqp__routingKey=test 61 | - spring__application__name=csv-service 62 | - eureka__client__serviceUrl=${SERVICEREGISTRYURL} 63 | - eureka__client__shouldFetchRegistry=${CLIENTSHOULDFETCHREGISTRY} 64 | - eureka__client__shouldRegisterWithEureka=${CLIENTSHOULDREGISTERWITHEUREKA} 65 | - eureka__instance__port=20047 66 | - tokenManagement__secret=${TOKENSECRET} 67 | - tokenManagement__issuer=${TOKENISSUER} 68 | - tokenManagement__audience=${TOKENAUDIENCE} 69 | - tokenManagement__accessExpiration=${TOKENACCESSEXPIRATION} 70 | - tokenManagement__refreshExpiration=${TOKENREFRESHEXPIRATION} 71 | # volumes: 72 | # - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro 73 | # - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro 74 | build: 75 | args: 76 | - CUSTOM_FEED_USERNAME=${PACKAGEFEEDUSER} 77 | - CUSTOM_FEED_PERSONAL_ACCESS_TOKEN=${PACKAGEPERSONALACCESSTOEKN} 78 | ports: 79 | - "20046:80" 80 | # - "44360:443" 81 | 82 | shopping-cart-service: 83 | restart: ${SERVICERESTARTBEHAVIOUR} 84 | environment: 85 | - ASPNETCORE_ENVIRONMENT=Development 86 | # - ASPNETCORE_URLS=https://+:443;http://+:80 87 | - ASPNETCORE_URLS=http://+:80 88 | - ASPNETCORE_HTTPS_PORT=44365 89 | - ConnectionStrings__DefaultConnection=Server=sql.data,1433;Database=ShoppingCartMSDb;User Id=${SQLDATABASEUSER};Password=${SQLDATABASEPASSWORD}; 90 | - spring__application__name=shopping-cart-service 91 | - eureka__client__serviceUrl=${SERVICEREGISTRYURL} 92 | - eureka__client__shouldFetchRegistry=${CLIENTSHOULDFETCHREGISTRY} 93 | - eureka__client__shouldRegisterWithEureka=${CLIENTSHOULDREGISTERWITHEUREKA} 94 | - eureka__instance__port=20052 95 | - tokenManagement__secret=${TOKENSECRET} 96 | - tokenManagement__issuer=${TOKENISSUER} 97 | - tokenManagement__audience=${TOKENAUDIENCE} 98 | - tokenManagement__accessExpiration=${TOKENACCESSEXPIRATION} 99 | - tokenManagement__refreshExpiration=${TOKENREFRESHEXPIRATION} 100 | - amqp__hostName=${AMQPHOST} 101 | - amqp__exchange=test.exchange 102 | - amqp__queueName=test.queue 103 | - amqp__routingKey=test 104 | # volumes: 105 | # - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro 106 | # - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro 107 | build: 108 | args: 109 | - CUSTOM_FEED_USERNAME=${PACKAGEFEEDUSER} 110 | - CUSTOM_FEED_PERSONAL_ACCESS_TOKEN=${PACKAGEPERSONALACCESSTOEKN} 111 | ports: 112 | - "20047:80" 113 | # - "44365:443" 114 | 115 | sql.data: 116 | build: 117 | args: 118 | - PASSWORD=${SQLDATABASEPASSWORD} -------------------------------------------------------------------------------- /.docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | # Microservices 5 | authentication-service: 6 | image: ${DOCKER_REGISTRY-}authenticationservice 7 | build: 8 | context: ../services/authentication-service 9 | networks: 10 | - onboarding 11 | depends_on: 12 | - sql.data 13 | # - service-registry 14 | # entrypoint: "./wait-for-it.sh sql.data:1433 -- dotnet authentication-service.dll" 15 | 16 | 17 | csv-service: 18 | image: ${DOCKER_REGISTRY-}csvservice 19 | build: 20 | context: ../services/csv-service 21 | networks: 22 | - onboarding 23 | depends_on: 24 | - authentication-service 25 | # - service-registry 26 | 27 | 28 | shopping-cart-service: 29 | image: ${DOCKER_REGISTRY-}shoppingcartservice 30 | build: 31 | context: ../services/shopping-cart-service 32 | networks: 33 | - onboarding 34 | depends_on: 35 | - authentication-service 36 | # - service-registry 37 | 38 | 39 | # Infrastructure & Databases 40 | sql.data: 41 | image: ${DOCKER_REGISTRY-}sqlserverservice 42 | build: ../.infrastructure/sql.data 43 | ports: 44 | - "1433:1433" 45 | networks: 46 | - onboarding 47 | 48 | mongo.data: 49 | image: mongo 50 | hostname: mongo.data 51 | ports: 52 | - "27017:27017" 53 | networks: 54 | - onboarding 55 | 56 | 57 | 58 | # Networks 59 | networks: 60 | onboarding: 61 | driver: bridge 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | # Infrastructure & Databases 85 | 86 | # sql.data: 87 | # image: microsoft/mssql-server-linux 88 | # environment: 89 | # - SA_PASSWORD=P@ssw0rd1 90 | # - ACCEPT_EULA=Y 91 | # ports: 92 | # - "1433:1433" 93 | # networks: 94 | # - onboarding 95 | 96 | # service.bus: 97 | # build: ../.infrastructure/service-bus 98 | # hostname: service.bus 99 | # ports: 100 | # - "15672:15672" 101 | # - "5672:5672" 102 | # networks: 103 | # - onboarding 104 | 105 | # healthcheck: 106 | # test: ["CMD", "curl", "-f", "http://localhost:15672"] 107 | # interval: 30s 108 | # timeout: 10s 109 | # retries: 8 110 | 111 | # service-registry: 112 | # image: ${DOCKER_REGISTRY-}serviceregistry 113 | # build: ../service-registry 114 | # ports: 115 | # - "8761:8761" 116 | # networks: 117 | # - onboarding 118 | # healthcheck: 119 | # test: ["CMD", "curl", "-f", "http://localhost:8761"] 120 | # interval: 30s 121 | # timeout: 10s 122 | # retries: 8 123 | 124 | 125 | # Frontend & BFF 126 | # api-gateway: 127 | # image: ${DOCKER_REGISTRY-}customerportalapigateway 128 | # build: 129 | # context: . 130 | # dockerfile: Dockerfile 131 | # networks: 132 | # - onboarding 133 | # depends_on: 134 | # - customers-service 135 | # - csv-service 136 | # - authentication-service 137 | # - face-ai-service 138 | # - ocr-ai-service 139 | # - service.bus 140 | # - service.registry 141 | # - shopping-cart-service 142 | 143 | # frontend: 144 | # restart: ${SERVICERESTARTBEHAVIOUR} 145 | # image: ${DOCKER_REGISTRY-}onboardingprototype 146 | # build: ../onboarding-prototype 147 | # env_file: ../onboarding-prototype/.env 148 | # networks: 149 | # - onboarding 150 | # ports: 151 | # - "4000:3000" 152 | # # depends_on: 153 | # # - api-gateway 154 | 155 | 156 | # Microservices 157 | 158 | # notifications-service: 159 | # image: ${DOCKER_REGISTRY-}notifications-service 160 | # build: 161 | # context: ../notifications-service 162 | # networks: 163 | # - onboarding 164 | # depends_on: 165 | # - authentication-service 166 | # - service-registry 167 | 168 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/frontend 2 | **/services 3 | # **/services/csv-service 4 | # **/services/Services.Common 5 | # **/services/shopping-cart-service 6 | **/.env 7 | **/.env.dev 8 | **/.env.stable 9 | **/.env.prod -------------------------------------------------------------------------------- /.infrastructure/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javaniecampbell/demo/ebecdb78528aad6f6de5358803aa2768c16f9f71/.infrastructure/.gitkeep -------------------------------------------------------------------------------- /.infrastructure/sql.data/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/mssql-server-linux 2 | COPY /scripts/authentication.batch.sql . 3 | COPY /scripts/business.customers.batch.sql . 4 | COPY /scripts/shoppingcart.batch.sql . 5 | COPY /scripts/history.batch.sql . 6 | EXPOSE 1433 7 | 8 | ARG PASSWORD 9 | ENV ACCEPT_EULA Y 10 | ENV SA_PASSWORD ${PASSWORD} 11 | 12 | RUN /opt/mssql/bin/sqlservr --accept-eula & sleep 65 \ 13 | && /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${PASSWORD} -d master -i authentication.batch.sql -I \ 14 | && pkill sqlservr 15 | 16 | RUN /opt/mssql/bin/sqlservr --accept-eula & sleep 85 \ 17 | && /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${PASSWORD} -d master -i business.customers.batch.sql -I \ 18 | && pkill sqlservr 19 | 20 | RUN /opt/mssql/bin/sqlservr --accept-eula & sleep 105 \ 21 | && /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${PASSWORD} -d master -i shoppingcart.batch.sql -I \ 22 | && pkill sqlservr 23 | 24 | RUN /opt/mssql/bin/sqlservr --accept-eula & sleep 135 \ 25 | && /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${PASSWORD} -d master -i history.batch.sql -I \ 26 | && pkill sqlservr 27 | 28 | # RUN ["/opt/mssql-tools/bin/sqlcmd","-i","authentication.batch.sql"] 29 | # RUN ["sqlcmd","-1","history.batch.sql"] 30 | 31 | 32 | -------------------------------------------------------------------------------- /.infrastructure/sql.data/scripts/authentication.batch.sql: -------------------------------------------------------------------------------- 1 | -- DECLARE @dbname varchar(128) 2 | -- SET @dbname = N'OnboardingAuthDB' 3 | 4 | -- IF (NOT EXISTS (SELECT name 5 | -- FROM master.dbo.sysdatabases 6 | -- WHERE ('[' + name + ']' = @dbname 7 | -- OR name = @dbname))) 8 | -- BEGIN 9 | CREATE DATABASE OnboardingAuthDB; 10 | -- END; 11 | GO 12 | USE OnboardingAuthDB; 13 | GO 14 | -- Generated Script modify below -- 15 | ----------------------------------- 16 | IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL 17 | BEGIN 18 | CREATE TABLE [__EFMigrationsHistory] ( 19 | [MigrationId] varchar(150) NOT NULL, 20 | [ProductVersion] varchar(32) NOT NULL, 21 | CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) 22 | ); 23 | END; 24 | 25 | GO 26 | 27 | CREATE TABLE [AspNetRoles] ( 28 | [Id] varchar(450) NOT NULL, 29 | [Name] varchar(256) NULL, 30 | [NormalizedName] varchar(256) NULL, 31 | [ConcurrencyStamp] varchar(max) NULL, 32 | CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id]) 33 | ); 34 | 35 | GO 36 | 37 | CREATE TABLE [AspNetUsers] ( 38 | [Id] varchar(450) NOT NULL, 39 | [UserName] varchar(256) NULL, 40 | [NormalizedUserName] varchar(256) NULL, 41 | [Email] varchar(256) NULL, 42 | [NormalizedEmail] varchar(256) NULL, 43 | [EmailConfirmed] bit NOT NULL, 44 | [PasswordHash] varchar(max) NULL, 45 | [SecurityStamp] varchar(max) NULL, 46 | [ConcurrencyStamp] varchar(max) NULL, 47 | [PhoneNumber] varchar(max) NULL, 48 | [PhoneNumberConfirmed] bit NOT NULL, 49 | [TwoFactorEnabled] bit NOT NULL, 50 | [LockoutEnd] datetimeoffset NULL, 51 | [LockoutEnabled] bit NOT NULL, 52 | [AccessFailedCount] int NOT NULL, 53 | [FirstName] varchar(max) NULL, 54 | [LastName] varchar(max) NULL, 55 | CONSTRAINT [PK_AspNetUsers] PRIMARY KEY ([Id]) 56 | ); 57 | 58 | GO 59 | 60 | CREATE TABLE [AspNetRoleClaims] ( 61 | [Id] int NOT NULL IDENTITY, 62 | [RoleId] varchar(450) NOT NULL, 63 | [ClaimType] varchar(max) NULL, 64 | [ClaimValue] varchar(max) NULL, 65 | CONSTRAINT [PK_AspNetRoleClaims] PRIMARY KEY ([Id]), 66 | CONSTRAINT [FK_AspNetRoleClaims_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE 67 | ); 68 | 69 | GO 70 | 71 | CREATE TABLE [AspNetUserClaims] ( 72 | [Id] int NOT NULL IDENTITY, 73 | [UserId] varchar(450) NOT NULL, 74 | [ClaimType] varchar(max) NULL, 75 | [ClaimValue] varchar(max) NULL, 76 | CONSTRAINT [PK_AspNetUserClaims] PRIMARY KEY ([Id]), 77 | CONSTRAINT [FK_AspNetUserClaims_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE 78 | ); 79 | 80 | GO 81 | 82 | CREATE TABLE [AspNetUserLogins] ( 83 | [LoginProvider] varchar(450) NOT NULL, 84 | [ProviderKey] varchar(450) NOT NULL, 85 | [ProviderDisplayName] varchar(max) NULL, 86 | [UserId] varchar(450) NOT NULL, 87 | CONSTRAINT [PK_AspNetUserLogins] PRIMARY KEY ([LoginProvider], [ProviderKey]), 88 | CONSTRAINT [FK_AspNetUserLogins_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE 89 | ); 90 | 91 | GO 92 | 93 | CREATE TABLE [AspNetUserRoles] ( 94 | [UserId] varchar(450) NOT NULL, 95 | [RoleId] varchar(450) NOT NULL, 96 | CONSTRAINT [PK_AspNetUserRoles] PRIMARY KEY ([UserId], [RoleId]), 97 | CONSTRAINT [FK_AspNetUserRoles_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE, 98 | CONSTRAINT [FK_AspNetUserRoles_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE 99 | ); 100 | 101 | GO 102 | 103 | CREATE TABLE [AspNetUserTokens] ( 104 | [UserId] varchar(450) NOT NULL, 105 | [LoginProvider] varchar(450) NOT NULL, 106 | [Name] varchar(450) NOT NULL, 107 | [Value] varchar(max) NULL, 108 | CONSTRAINT [PK_AspNetUserTokens] PRIMARY KEY ([UserId], [LoginProvider], [Name]), 109 | CONSTRAINT [FK_AspNetUserTokens_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE 110 | ); 111 | 112 | GO 113 | 114 | CREATE INDEX [IX_AspNetRoleClaims_RoleId] ON [AspNetRoleClaims] ([RoleId]); 115 | 116 | GO 117 | 118 | CREATE UNIQUE INDEX [RoleNameIndex] ON [AspNetRoles] ([NormalizedName]) WHERE [NormalizedName] IS NOT NULL; 119 | 120 | GO 121 | 122 | CREATE INDEX [IX_AspNetUserClaims_UserId] ON [AspNetUserClaims] ([UserId]); 123 | 124 | GO 125 | 126 | CREATE INDEX [IX_AspNetUserLogins_UserId] ON [AspNetUserLogins] ([UserId]); 127 | 128 | GO 129 | 130 | CREATE INDEX [IX_AspNetUserRoles_RoleId] ON [AspNetUserRoles] ([RoleId]); 131 | 132 | GO 133 | 134 | CREATE INDEX [EmailIndex] ON [AspNetUsers] ([NormalizedEmail]); 135 | 136 | GO 137 | 138 | CREATE UNIQUE INDEX [UserNameIndex] ON [AspNetUsers] ([NormalizedUserName]) WHERE [NormalizedUserName] IS NOT NULL; 139 | 140 | GO 141 | 142 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 143 | VALUES (N'20190606210459_InitialMigration', N'2.2.4-servicing-10062'); 144 | 145 | GO 146 | 147 | DROP INDEX [UserNameIndex] ON [AspNetUsers]; 148 | 149 | GO 150 | 151 | DROP INDEX [RoleNameIndex] ON [AspNetRoles]; 152 | 153 | GO 154 | 155 | CREATE TABLE [RefreshTokens] ( 156 | [Token] varchar(450) NOT NULL, 157 | [JwtId] varchar(max) NULL, 158 | [CreationDate] datetime2 NOT NULL, 159 | [ExpiryDate] datetime2 NOT NULL, 160 | [IsUsed] bit NOT NULL, 161 | [IsInvalidated] bit NOT NULL, 162 | [UserId] varchar(450) NULL, 163 | CONSTRAINT [PK_RefreshTokens] PRIMARY KEY ([Token]), 164 | CONSTRAINT [FK_RefreshTokens_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE NO ACTION 165 | ); 166 | 167 | GO 168 | 169 | CREATE UNIQUE INDEX [UserNameIndex] ON [AspNetUsers] ([NormalizedUserName]); 170 | 171 | GO 172 | 173 | CREATE UNIQUE INDEX [RoleNameIndex] ON [AspNetRoles] ([NormalizedName]); 174 | 175 | GO 176 | 177 | CREATE INDEX [IX_RefreshTokens_UserId] ON [RefreshTokens] ([UserId]); 178 | 179 | GO 180 | 181 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 182 | VALUES (N'20191019171836_AddedRefreshToken', N'2.2.4-servicing-10062'); 183 | 184 | GO -------------------------------------------------------------------------------- /.infrastructure/sql.data/scripts/business.customers.batch.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE [business-customers]; 2 | GO 3 | USE [business-customers]; 4 | GO 5 | -- Generated Script modify below -- 6 | ----------------------------------- 7 | IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL 8 | BEGIN 9 | CREATE TABLE [__EFMigrationsHistory] ( 10 | [MigrationId] nvarchar(150) NOT NULL, 11 | [ProductVersion] nvarchar(32) NOT NULL, 12 | CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) 13 | ); 14 | END; 15 | 16 | GO 17 | 18 | CREATE TABLE [Companies] ( 19 | [Id] uniqueidentifier NOT NULL, 20 | [Name] nvarchar(max) NULL, 21 | [Address] nvarchar(max) NULL, 22 | [DateIncorporated] datetime2 NOT NULL, 23 | CONSTRAINT [PK_Companies] PRIMARY KEY ([Id]) 24 | ); 25 | 26 | GO 27 | 28 | CREATE TABLE [DocumentTypes] ( 29 | [Id] int NOT NULL IDENTITY, 30 | [Type] nvarchar(max) NULL, 31 | CONSTRAINT [PK_DocumentTypes] PRIMARY KEY ([Id]) 32 | ); 33 | 34 | GO 35 | 36 | CREATE TABLE [BusinessAccountManagers] ( 37 | [Id] uniqueidentifier NOT NULL, 38 | [Email] nvarchar(max) NULL, 39 | [FirstName] nvarchar(max) NULL, 40 | [LastName] nvarchar(max) NULL, 41 | [PhotoUrl] nvarchar(max) NULL, 42 | [IsRegistered] bit NOT NULL DEFAULT CAST(0 AS bit), 43 | [CompanyId] uniqueidentifier NOT NULL, 44 | CONSTRAINT [PK_BusinessAccountManagers] PRIMARY KEY ([Id]), 45 | CONSTRAINT [FK_BusinessAccountManagers_Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [Companies] ([Id]) ON DELETE CASCADE 46 | ); 47 | 48 | GO 49 | 50 | CREATE TABLE [ContactInformation] ( 51 | [Id] uniqueidentifier NOT NULL, 52 | [Email] nvarchar(max) NULL, 53 | [Phone] nvarchar(max) NULL, 54 | [CompanyId] uniqueidentifier NOT NULL, 55 | CONSTRAINT [PK_ContactInformation] PRIMARY KEY ([Id]), 56 | CONSTRAINT [FK_ContactInformation_Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [Companies] ([Id]) ON DELETE CASCADE 57 | ); 58 | 59 | GO 60 | 61 | CREATE TABLE [Customers] ( 62 | [Id] uniqueidentifier NOT NULL, 63 | [CompanyName] nvarchar(max) NULL, 64 | [CreditLimit] int NULL, 65 | [Trn] int NOT NULL, 66 | [Address] nvarchar(max) NULL, 67 | [YearsOfBusiness] int NULL, 68 | [CompanyId] uniqueidentifier NOT NULL, 69 | CONSTRAINT [PK_Customers] PRIMARY KEY ([Id]), 70 | CONSTRAINT [FK_Customers_Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [Companies] ([Id]) ON DELETE CASCADE 71 | ); 72 | 73 | GO 74 | 75 | CREATE TABLE [Documents] ( 76 | [Id] uniqueidentifier NOT NULL, 77 | [DocumentId] nvarchar(max) NULL, 78 | [DocumentTypeId] int NOT NULL, 79 | [CustomerId] uniqueidentifier NOT NULL, 80 | [CreatedBy] uniqueidentifier NOT NULL, 81 | [CreatedAt] datetimeoffset NOT NULL, 82 | [LastModifiedAt] datetimeoffset NOT NULL, 83 | [LastModifiedBy] uniqueidentifier NOT NULL, 84 | [isActive] bit NOT NULL, 85 | CONSTRAINT [PK_Documents] PRIMARY KEY ([Id]), 86 | CONSTRAINT [FK_Documents_Customers_CustomerId] FOREIGN KEY ([CustomerId]) REFERENCES [Customers] ([Id]) ON DELETE CASCADE, 87 | CONSTRAINT [FK_Documents_DocumentTypes_DocumentTypeId] FOREIGN KEY ([DocumentTypeId]) REFERENCES [DocumentTypes] ([Id]) ON DELETE CASCADE 88 | ); 89 | 90 | GO 91 | 92 | CREATE TABLE [Representatives] ( 93 | [Id] uniqueidentifier NOT NULL, 94 | [FirstName] nvarchar(max) NULL, 95 | [LastName] nvarchar(max) NULL, 96 | [MiddleName] nvarchar(max) NULL, 97 | [DateOfBirth] datetime2 NOT NULL, 98 | [JobTitle] nvarchar(max) NULL, 99 | [GenderId] int NOT NULL, 100 | [Nationality] nvarchar(max) NULL, 101 | [Email] nvarchar(max) NULL, 102 | [ContactNumber] nvarchar(max) NULL, 103 | [Primary] bit NOT NULL, 104 | [CustomerId] uniqueidentifier NOT NULL, 105 | CONSTRAINT [PK_Representatives] PRIMARY KEY ([Id]), 106 | CONSTRAINT [FK_Representatives_Customers_CustomerId] FOREIGN KEY ([CustomerId]) REFERENCES [Customers] ([Id]) ON DELETE CASCADE 107 | ); 108 | 109 | GO 110 | 111 | CREATE TABLE [Contracts] ( 112 | [Id] uniqueidentifier NOT NULL, 113 | [status] nvarchar(max) NULL, 114 | [MonthlyPayment] real NOT NULL, 115 | [TotalCashPrice] real NOT NULL, 116 | [DeliveryDate] datetimeoffset NULL, 117 | [StartDateOfContract] datetimeoffset NULL, 118 | [EndDateOFContract] datetimeoffset NULL, 119 | [DateSigned] datetimeoffset NULL, 120 | [LastUpdated] datetimeoffset NOT NULL, 121 | [LastUpdatedBy] uniqueidentifier NOT NULL, 122 | [CreatedBy] uniqueidentifier NOT NULL, 123 | [CreatedOn] datetimeoffset NOT NULL, 124 | [isActive] bit NOT NULL, 125 | [RepresentativeId] uniqueidentifier NOT NULL, 126 | CONSTRAINT [PK_Contracts] PRIMARY KEY ([Id]), 127 | CONSTRAINT [FK_Contracts_Representatives_RepresentativeId] FOREIGN KEY ([RepresentativeId]) REFERENCES [Representatives] ([Id]) ON DELETE CASCADE 128 | ); 129 | 130 | GO 131 | 132 | CREATE TABLE [Policies] ( 133 | [Id] uniqueidentifier NOT NULL, 134 | [DeviceId] nvarchar(max) NULL, 135 | [Imei] nvarchar(max) NULL, 136 | [PolicyStartDate] datetimeoffset NOT NULL, 137 | [PolicyEndDate] datetimeoffset NOT NULL, 138 | [ContractId] uniqueidentifier NOT NULL, 139 | [CreatedBy] uniqueidentifier NOT NULL, 140 | [CreatedOn] datetimeoffset NOT NULL, 141 | [CompanyId] uniqueidentifier NOT NULL, 142 | [CustomerId] uniqueidentifier NOT NULL, 143 | CONSTRAINT [PK_Policies] PRIMARY KEY ([Id]), 144 | CONSTRAINT [FK_Policies_Contracts_ContractId] FOREIGN KEY ([ContractId]) REFERENCES [Contracts] ([Id]) ON DELETE CASCADE 145 | ); 146 | 147 | GO 148 | 149 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Address', N'DateIncorporated', N'Name') AND [object_id] = OBJECT_ID(N'[Companies]')) 150 | SET IDENTITY_INSERT [Companies] ON; 151 | INSERT INTO [Companies] ([Id], [Address], [DateIncorporated], [Name]) 152 | VALUES ('3b2195ec-d3cf-4106-f77e-08d746adadff', N'12 Ruthven Rd, Kingston', '2009-10-10T00:00:00.0000000', N'Smart Mobile Solutions'); 153 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Address', N'DateIncorporated', N'Name') AND [object_id] = OBJECT_ID(N'[Companies]')) 154 | SET IDENTITY_INSERT [Companies] OFF; 155 | 156 | GO 157 | 158 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[DocumentTypes]')) 159 | SET IDENTITY_INSERT [DocumentTypes] ON; 160 | INSERT INTO [DocumentTypes] ([Id], [Type]) 161 | VALUES (1, N'DriversLicense_Front'), 162 | (2, N'DriversLicense_Back'), 163 | (3, N'Passport_Page1'), 164 | (4, N'Passport_Page2'), 165 | (5, N'VotersId_Back'), 166 | (6, N'VotersId_Front'), 167 | (7, N'Avatar'), 168 | (8, N'JobLetter'), 169 | (9, N'Proof_of_Address'), 170 | (10, N'Proof_of_Income'), 171 | (11, N'Proof_Of_Registration'), 172 | (12, N'Letter_Of_Undertaking'), 173 | (13, N'Contracts'); 174 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[DocumentTypes]')) 175 | SET IDENTITY_INSERT [DocumentTypes] OFF; 176 | 177 | GO 178 | 179 | CREATE INDEX [IX_BusinessAccountManagers_CompanyId] ON [BusinessAccountManagers] ([CompanyId]); 180 | 181 | GO 182 | 183 | CREATE INDEX [IX_ContactInformation_CompanyId] ON [ContactInformation] ([CompanyId]); 184 | 185 | GO 186 | 187 | CREATE INDEX [IX_Contracts_RepresentativeId] ON [Contracts] ([RepresentativeId]); 188 | 189 | GO 190 | 191 | CREATE INDEX [IX_Customers_CompanyId] ON [Customers] ([CompanyId]); 192 | 193 | GO 194 | 195 | CREATE INDEX [IX_Documents_CustomerId] ON [Documents] ([CustomerId]); 196 | 197 | GO 198 | 199 | CREATE INDEX [IX_Documents_DocumentTypeId] ON [Documents] ([DocumentTypeId]); 200 | 201 | GO 202 | 203 | CREATE INDEX [IX_Policies_ContractId] ON [Policies] ([ContractId]); 204 | 205 | GO 206 | 207 | CREATE INDEX [IX_Representatives_CustomerId] ON [Representatives] ([CustomerId]); 208 | 209 | GO 210 | 211 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 212 | VALUES (N'20191211211217_InitialMigration', N'3.0.0'); 213 | 214 | GO 215 | 216 | ALTER TABLE [Policies] ADD [PolicyNumber] int NOT NULL IDENTITY; 217 | 218 | GO 219 | 220 | ALTER TABLE [Contracts] ADD [ContractNumber] int NOT NULL IDENTITY; 221 | 222 | GO 223 | 224 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 225 | VALUES (N'20191212151437_AddedAutoIncrementFieldToPolicyAndCustomerTable', N'3.0.0'); 226 | 227 | GO 228 | 229 | ALTER TABLE [Contracts] ADD [DocumentId] uniqueidentifier NULL; 230 | 231 | GO 232 | 233 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 234 | VALUES (N'20191216222144_AddedDocumentIdToContractsTable', N'3.0.0'); 235 | 236 | GO 237 | 238 | ALTER TABLE [Contracts] ADD [InvoiceDocumentId] uniqueidentifier NULL; 239 | 240 | GO 241 | 242 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 243 | VALUES (N'20191219223916_AddedInvioceDocumentIdToContractTable', N'3.0.0'); 244 | 245 | GO 246 | 247 | ALTER TABLE [Contracts] ADD [OrderId] nvarchar(max) NULL; 248 | 249 | GO 250 | 251 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 252 | VALUES (N'20191220154537_AddedOrderIdToContractTable', N'3.0.0'); 253 | 254 | GO 255 | 256 | CREATE TABLE [Genders] ( 257 | [Id] int NOT NULL IDENTITY, 258 | [Type] nvarchar(max) NOT NULL, 259 | CONSTRAINT [PK_Genders] PRIMARY KEY ([Id]) 260 | ); 261 | 262 | GO 263 | 264 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[Genders]')) 265 | SET IDENTITY_INSERT [Genders] ON; 266 | INSERT INTO [Genders] ([Id], [Type]) 267 | VALUES (1, N'Male'); 268 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[Genders]')) 269 | SET IDENTITY_INSERT [Genders] OFF; 270 | 271 | GO 272 | 273 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[Genders]')) 274 | SET IDENTITY_INSERT [Genders] ON; 275 | INSERT INTO [Genders] ([Id], [Type]) 276 | VALUES (2, N'Female'); 277 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[Genders]')) 278 | SET IDENTITY_INSERT [Genders] OFF; 279 | 280 | GO 281 | 282 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[Genders]')) 283 | SET IDENTITY_INSERT [Genders] ON; 284 | INSERT INTO [Genders] ([Id], [Type]) 285 | VALUES (3, N'Unspecified'); 286 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[Genders]')) 287 | SET IDENTITY_INSERT [Genders] OFF; 288 | 289 | GO 290 | 291 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 292 | VALUES (N'20200103185742_Added Gender Table', N'3.0.0'); 293 | 294 | GO 295 | 296 | CREATE INDEX [IX_Representatives_GenderId] ON [Representatives] ([GenderId]); 297 | 298 | GO 299 | 300 | ALTER TABLE [Representatives] ADD CONSTRAINT [FK_Representatives_Genders_GenderId] FOREIGN KEY ([GenderId]) REFERENCES [Genders] ([Id]) ON DELETE CASCADE; 301 | 302 | GO 303 | 304 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 305 | VALUES (N'20200103190225_Added Gender Foreign key to Representative Table', N'3.0.0'); 306 | 307 | GO 308 | 309 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[DocumentTypes]')) 310 | SET IDENTITY_INSERT [DocumentTypes] ON; 311 | INSERT INTO [DocumentTypes] ([Id], [Type]) 312 | VALUES (14, N'Certification_Of_Incorporation'), 313 | (15, N'Tax_Compliance_Certification'), 314 | (16, N'Invoice'), 315 | (17, N'Delivery_Slip'); 316 | IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Type') AND [object_id] = OBJECT_ID(N'[DocumentTypes]')) 317 | SET IDENTITY_INSERT [DocumentTypes] OFF; 318 | 319 | GO 320 | 321 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 322 | VALUES (N'20200206195823_added_delivery_slip_param_to_contract_entity', N'3.0.0'); 323 | 324 | GO 325 | 326 | ALTER TABLE [Contracts] ADD [DeliverySlipDocumentId] uniqueidentifier NULL; 327 | 328 | GO 329 | 330 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 331 | VALUES (N'20200207032107_added_delivery_slip_id_to_contracts', N'3.0.0'); 332 | 333 | GO 334 | 335 | 336 | -- Inserts Script modify below -- 337 | ----------------------------------- 338 | 339 | -- Companies 340 | SET IDENTITY_INSERT [business-customers].dbo.Companies ON; 341 | GO 342 | 343 | INSERT INTO [business-customers].dbo.Companies (Id, [Name], [Address], DateIncorporated) VALUES ('3B2195EC-D3CF-4106-F77E-08D746ADADFF', 'Smart Mobile Solutions', '12 Ruthven Rd, Kingston', '2009-10-10 00:00:00.0000000'); 344 | GO 345 | 346 | SET IDENTITY_INSERT [business-customers].dbo.Companies OFF; 347 | GO 348 | 349 | -- Customers 350 | SET IDENTITY_INSERT [business-customers].dbo.Customers ON; 351 | GO 352 | 353 | -- INSERT INTO [business-customers].dbo.Customers (Id, CompanyName, CreditLimit, Trn, Address, YearsOfBusiness, CompanyId) VALUES ('4631E87D-186B-4496-B059-08D77E7F607C', 'GelCo', 100, 111222333, '14 Ocean Blvd, Kingston', 9, '3B2195EC-D3CF-4106-F77E-08D746ADADFF'); 354 | -- GO 355 | 356 | -- INSERT INTO [business-customers].dbo.Customers (Id, CompanyName, CreditLimit, Trn, Address, YearsOfBusiness, CompanyId) VALUES ('9C581C87-3EB5-4254-FF33-08D7A333EDD7', 'JC Penny', 100, 111222333, '14 Ocean Blvd, Kingston', 9, '3B2195EC-D3CF-4106-F77E-08D746ADADFF'); 357 | -- GO 358 | 359 | SET IDENTITY_INSERT [business-customers].dbo.Customers OFF; 360 | GO 361 | 362 | 363 | --Representatives 364 | SET IDENTITY_INSERT [business-customers].dbo.Representatives ON; 365 | GO 366 | 367 | -- INSERT INTO [business-customers].dbo.Representatives (Id, FirstName, LastName, MiddleName, DateOfBirth, JobTitle, GenderId, Nationality, Email, ContactNumber, [Primary], CustomerId) VALUES ('0701EB7F-390A-43D6-94C6-08D77E7F60E5', 'Akinyele', 'Thompson', 'Omowale', '1994-03-24 00:00:00.0000000', 'CEO', 1, 'Jamaican', 'akinyele@email.com', '18768887777', 1, '4631E87D-186B-4496-B059-08D77E7F607C'); 368 | -- GO 369 | 370 | -- INSERT INTO [business-customers].dbo.Representatives (Id, FirstName, LastName, MiddleName, DateOfBirth, JobTitle, GenderId, Nationality, Email, ContactNumber, [Primary], CustomerId) VALUES ('4C608CE8-2F09-41E1-7906-08D7A333EE27', 'Howard', 'Edwards', 'Edwards', '1994-03-03 00:00:00.0000000', 'CEO', 1, null, 'howard.edwards@gmail.com', '87644138943', 1, '9C581C87-3EB5-4254-FF33-08D7A333EDD7'); 371 | -- GO 372 | 373 | SET IDENTITY_INSERT [business-customers].dbo.Representatives OFF; 374 | GO 375 | 376 | -- Contracts 377 | --SET IDENTITY_INSERT dbo.Contracts ON; 378 | --GO 379 | -- 380 | --INSERT INTO [business-customers].dbo.Contracts (Id, [status], MonthlyPayment, TotalCashPrice, DeliveryDate, StartDateOfContract, EndDateOFContract, DateSigned, LastUpdated, LastUpdatedBy, CreatedBy, CreatedOn, isActive, RepresentativeId, ContractNumber, DocumentId) VALUES ('16BBB926-8153-4609-3131-08D77F17C52B', 'Active', 100000, 100000000, null, null, null, null, '2019-12-12 10:27:16.4730550 -05:00', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '2019-12-12 10:27:16.4732490 -05:00', 1, 'B84930C4-0861-4FB8-B733-08D77F16698C', 1, null); 381 | --GO 382 | --INSERT INTO [business-customers].dbo.Contracts (Id, [status], MonthlyPayment, TotalCashPrice, DeliveryDate, StartDateOfContract, EndDateOFContract, DateSigned, LastUpdated, LastUpdatedBy, CreatedBy, CreatedOn, isActive, RepresentativeId, ContractNumber, DocumentId) VALUES ('87F24994-31AB-4F80-3132-08D77F17C52B', 'Active', 100000, 100000000, null, null, null, null, '2019-12-12 10:27:53.5387990 -05:00', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '2019-12-12 10:27:53.5388320 -05:00', 1, 'B84930C4-0861-4FB8-B733-08D77F16698C', 2, null); 383 | --GO 384 | --INSERT INTO [business-customers].dbo.Contracts (Id, [status], MonthlyPayment, TotalCashPrice, DeliveryDate, StartDateOfContract, EndDateOFContract, DateSigned, LastUpdated, LastUpdatedBy, CreatedBy, CreatedOn, isActive, RepresentativeId, ContractNumber, DocumentId) VALUES ('36FE53A3-1829-4644-14E1-08D77F1871EF', 'Active', 100001, 100000000, null, null, null, null, '2019-12-12 11:12:36.3825120 -05:00', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '2019-12-12 10:32:06.3383900 -05:00', 1, 'B84930C4-0861-4FB8-B733-08D77F16698C', 3, null); 385 | --GO 386 | --INSERT INTO [business-customers].dbo.Contracts (Id, [status], MonthlyPayment, TotalCashPrice, DeliveryDate, StartDateOfContract, EndDateOFContract, DateSigned, LastUpdated, LastUpdatedBy, CreatedBy, CreatedOn, isActive, RepresentativeId, ContractNumber, DocumentId) VALUES ('5A2956B6-A755-47BE-2E45-08D7826CEFA1', 'Active', 100000, 100000000, null, null, null, null, '2019-12-16 16:14:28.4395640 -05:00', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '2019-12-16 16:14:28.4396250 -05:00', 1, 'B84930C4-0861-4FB8-B733-08D77F16698C', 1002, null); 387 | --GO 388 | --INSERT INTO [business-customers].dbo.Contracts (Id, [status], MonthlyPayment, TotalCashPrice, DeliveryDate, StartDateOfContract, EndDateOFContract, DateSigned, LastUpdated, LastUpdatedBy, CreatedBy, CreatedOn, isActive, RepresentativeId, ContractNumber, DocumentId) VALUES ('4CD78623-DE4B-4771-2D9F-08D7826D4245', 'Active', 100000, 100000000, null, null, null, null, '2019-12-16 16:16:36.7000190 -05:00', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '2019-12-16 16:16:36.7001530 -05:00', 1, 'B84930C4-0861-4FB8-B733-08D77F16698C', 1003, null); 389 | --GO 390 | --INSERT INTO [business-customers].dbo.Contracts (Id, [status], MonthlyPayment, TotalCashPrice, DeliveryDate, StartDateOfContract, EndDateOFContract, DateSigned, LastUpdated, LastUpdatedBy, CreatedBy, CreatedOn, isActive, RepresentativeId, ContractNumber, DocumentId) VALUES ('1D8A8BA3-ACCE-4CD8-BF33-08D7826DA9FD', 'Active', 100000, 100000000, null, null, null, null, '2019-12-16 16:19:41.0940910 -05:00', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '3B2195EC-D3CF-4106-F77E-08D746ADADFF', '2019-12-16 16:19:41.0941500 -05:00', 1, 'B84930C4-0861-4FB8-B733-08D77F16698C', 1004, null); 391 | --GO 392 | -- 393 | --SET IDENTITY_INSERT dbo.Contracts OFF; 394 | --GO -------------------------------------------------------------------------------- /.infrastructure/sql.data/scripts/history.batch.sql: -------------------------------------------------------------------------------- 1 | -- ============================================= 2 | -- Create database template 3 | -- ============================================= 4 | -- USE master 5 | -- GO 6 | 7 | -- Drop the database if it already exists 8 | -- IF EXISTS ( 9 | -- SELECT name 10 | -- FROM sys.databases 11 | -- WHERE name = N'historyStreamStore' 12 | -- ) 13 | -- DROP DATABASE [historyStreamStore] 14 | -- GO 15 | 16 | CREATE DATABASE [historyStreamStore]; 17 | GO 18 | 19 | USE [historyStreamStore]; 20 | GO 21 | 22 | -- ========================================= 23 | -- Create table Aggregates 24 | -- ========================================= 25 | USE [historyStreamStore]; 26 | GO 27 | 28 | IF OBJECT_ID('[dbo].[Events]', 'U') IS NOT NULL 29 | DROP TABLE[dbo].[Events] 30 | GO 31 | 32 | IF OBJECT_ID('[dbo].[Aggregates]', 'U') IS NOT NULL 33 | DROP TABLE[dbo].[Aggregates] 34 | GO 35 | 36 | CREATE TABLE [dbo].[Aggregates] 37 | ( 38 | [AggregateId] UNIQUEIDENTIFIER NOT NULL, 39 | [Type] VARCHAR(255) NOT NULL, 40 | [Version] BIGINT NULL, 41 | CONSTRAINT pk_Aggregate PRIMARY KEY (AggregateId) 42 | ) 43 | GO 44 | -- ========================================= 45 | -- Create table Events 46 | -- ========================================= 47 | USE [historyStreamStore]; 48 | GO 49 | 50 | IF OBJECT_ID('[dbo].[Events]', 'U') IS NOT NULL 51 | DROP TABLE[dbo].[Events] 52 | GO 53 | 54 | CREATE TABLE [dbo].[Events] 55 | ( 56 | [Id] UNIQUEIDENTIFIER NOT NULL, 57 | [Created] DATETIME NOT NULL, 58 | [AggregateType] NVARCHAR(255) NOT NULL, 59 | [AggregateId] UNIQUEIDENTIFIER NOT NULL, 60 | [Version] BIGINT NOT NULL, 61 | [Event] NVARCHAR(MAX) NOT NULL, 62 | [MetaData] NVARCHAR(MAX) NOT NULL, 63 | [Dispatched] BIT NOT NULL DEFAULT(0), 64 | [SequenceTimeStamp] DATETIME NOT NULL DEFAULT (CURRENT_TIMESTAMP), --This is used for events received out of order via asynchronous call 65 | CONSTRAINT pk_Events PRIMARY KEY (Id) --This creates a 1-to-1 relationship. 66 | ) 67 | GO 68 | 69 | ALTER TABLE [dbo].[Events] WITH CHECK ADD CONSTRAINT [FK_dbo.Events_dbo.Aggregates_AggregateId] FOREIGN KEY([AggregateId]) 70 | REFERENCES [dbo].[Aggregates] ([AggregateId]) 71 | GO 72 | -- ========================================= 73 | -- Create table Snapshots 74 | -- ========================================= 75 | USE [historyStreamStore]; 76 | GO 77 | 78 | IF OBJECT_ID('[dbo].[Snapshots]', 'U') IS NOT NULL 79 | DROP TABLE[dbo].[Snapshots] 80 | GO 81 | 82 | CREATE TABLE [dbo].[Snapshots] 83 | ( 84 | AggregateId UNIQUEIDENTIFIER NOT NULL, 85 | Version BIGINT NULL, 86 | [TimeStamp] DATETIME NOT NULL, 87 | Type NVARCHAR(255) NOT NULL, 88 | Data NVARCHAR(MAX) NOT NULL 89 | 90 | CONSTRAINT pk_EventSnapshots PRIMARY KEY (AggregateId) --This creates a 1-to-1 relationship. 91 | ) 92 | GO 93 | 94 | -------------------------------------------------------------------------------- /.infrastructure/sql.data/scripts/shoppingcart.batch.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE [ShoppingCartMSDb]; 2 | GO 3 | USE [ShoppingCartMSDb]; 4 | GO 5 | 6 | IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL 7 | BEGIN 8 | CREATE TABLE [__EFMigrationsHistory] ( 9 | [MigrationId] nvarchar(150) NOT NULL, 10 | [ProductVersion] nvarchar(32) NOT NULL, 11 | CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) 12 | ); 13 | END; 14 | 15 | GO 16 | 17 | CREATE TABLE [Carts] ( 18 | [CartId] uniqueidentifier NOT NULL, 19 | [DateCreatedOn] datetime2 NOT NULL, 20 | [DateModifiedOn] datetime2 NOT NULL, 21 | [CustomerId] uniqueidentifier NOT NULL, 22 | CONSTRAINT [PK_Carts] PRIMARY KEY ([CartId]) 23 | ); 24 | 25 | GO 26 | 27 | CREATE TABLE [Orders] ( 28 | [OrderId] uniqueidentifier NOT NULL, 29 | [CustomerId] uniqueidentifier NOT NULL, 30 | [Status] nvarchar(max) NULL, 31 | [CreatedOn] datetime2 NOT NULL, 32 | [DeliveredOn] datetime2 NULL, 33 | [ModifiedOn] datetime2 NULL, 34 | CONSTRAINT [PK_Orders] PRIMARY KEY ([OrderId]) 35 | ); 36 | 37 | GO 38 | 39 | CREATE TABLE [CartItem] ( 40 | [Id] int NOT NULL IDENTITY, 41 | [CartId] uniqueidentifier NOT NULL, 42 | [ProductId] nvarchar(450) NOT NULL, 43 | [Quantity] int NOT NULL, 44 | CONSTRAINT [PK_CartItem] PRIMARY KEY ([Id], [CartId], [ProductId]), 45 | CONSTRAINT [FK_CartItem_Carts_CartId] FOREIGN KEY ([CartId]) REFERENCES [Carts] ([CartId]) ON DELETE CASCADE ); 46 | 47 | 48 | CREATE TABLE [OrderItem] ( 49 | [Id] int NOT NULL IDENTITY, 50 | [OrderId] uniqueidentifier NOT NULL, 51 | [ProductId] nvarchar(450) NOT NULL, 52 | [Quantity] int NOT NULL, 53 | CONSTRAINT [PK_OrderItem] PRIMARY KEY ([Id], [OrderId], [ProductId]), 54 | CONSTRAINT [FK_OrderItem_Orders_OrderId] FOREIGN KEY ([OrderId]) REFERENCES [Orders] ([OrderId]) ON DELETE CASCADE ); 55 | 56 | GO 57 | 58 | CREATE INDEX [IX_CartItem_CartId] ON [CartItem] ([CartId]); 59 | 60 | GO 61 | 62 | CREATE INDEX [IX_OrderItem_OrderId] ON [OrderItem] ([OrderId]); 63 | 64 | GO 65 | 66 | INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) 67 | VALUES (N'20191202160311_ShoppingCartV1Schema', N'3.0.1'); 68 | 69 | GO -------------------------------------------------------------------------------- /.k8s/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javaniecampbell/demo/ebecdb78528aad6f6de5358803aa2768c16f9f71/.k8s/.gitkeep -------------------------------------------------------------------------------- /.scripts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javaniecampbell/demo/ebecdb78528aad6f6de5358803aa2768c16f9f71/.scripts/.gitkeep -------------------------------------------------------------------------------- /.scripts/new-project.ps1: -------------------------------------------------------------------------------- 1 | # [CmdletBinding()] 2 | # param ( 3 | # [Parameter()] 4 | # [string] 5 | # $ProjectName 6 | # ) 7 | 8 | $currentPath = Split-Path -Parent $MyInvocation.MyCommand.Definition 9 | 10 | $folders = @(".docker", ".infrastructure", ".k8s", ".scripts", ".tools",".services") 11 | Write-Host "Creating directories.." 12 | foreach ($folder in $folders) { 13 | # Write-Host "Creating directories at [$folder]..." 14 | mkdir "$currentPath\$folder" 15 | New-Item "$currentPath\$folder\.gitkeep" 16 | # Write-Host "[$folder] was created successfully" 17 | } 18 | Write-Host "Project was created successfully" 19 | 20 | Write-Host "Start hacking to launch 🚀" -------------------------------------------------------------------------------- /.scripts/start-rebuild.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | cd ../.docker/ 4 | docker-compose up --detach --build -------------------------------------------------------------------------------- /.scripts/start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ../.docker/ 4 | docker-compose up --detach --build -------------------------------------------------------------------------------- /.scripts/stop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ../.docker/ 4 | docker-compose down -------------------------------------------------------------------------------- /.scripts/stopAll.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | cd ../.docker/ 4 | docker-compose down -------------------------------------------------------------------------------- /.tools/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javaniecampbell/demo/ebecdb78528aad6f6de5358803aa2768c16f9f71/.tools/.gitkeep --------------------------------------------------------------------------------