├── .gitattributes ├── .gitignore ├── BlazorInvoiceApp ├── .cr │ └── personal │ │ └── FavoritesList │ │ └── List.xml ├── App.razor ├── Areas │ └── Identity │ │ ├── Pages │ │ ├── Account │ │ │ └── LogOut.cshtml │ │ └── Shared │ │ │ └── _LoginPartial.cshtml │ │ └── RevalidatingIdentityAuthenticationStateProvider.cs ├── BlazorInvoiceApp.csproj ├── BlazorInvoiceApp.sln ├── DTOS │ ├── CustomerDTO.cs │ ├── IDTO.cs │ ├── IOwnedDTO.cs │ ├── InvoiceDTO.cs │ ├── InvoiceLineItemDTO.cs │ └── InvoiceTermsDTO.cs ├── Data │ ├── ApplicationDbContext.cs │ ├── Customer.cs │ ├── IEntity.cs │ ├── IOwnedEntity.cs │ ├── Invoice.cs │ ├── InvoiceLineItem.cs │ ├── InvoiceTerms.cs │ └── Migrations │ │ ├── 00000000000000_CreateIdentitySchema.Designer.cs │ │ ├── 00000000000000_CreateIdentitySchema.cs │ │ ├── 20230926013249_db1.Designer.cs │ │ ├── 20230926013249_db1.cs │ │ └── ApplicationDbContextModelSnapshot.cs ├── Pages │ ├── Components │ │ ├── CustomerSetupComponent.razor │ │ ├── InvoiceDetailComponent.razor │ │ ├── InvoiceTermsSetupComponent.razor │ │ └── InvoicesComponent.razor │ ├── CustomerSetup.razor │ ├── EntityTest.razor │ ├── Error.cshtml │ ├── Error.cshtml.cs │ ├── Index.razor │ ├── InvoiceDetail.razor │ ├── InvoiceTermsSetup.razor │ └── _Host.cshtml ├── Program.cs ├── Properties │ ├── launchSettings.json │ ├── serviceDependencies.json │ └── serviceDependencies.local.json ├── Repository │ ├── AutoMapperProfile.cs │ ├── CustomerRepository.cs │ ├── GenericOwnedRepository.cs │ ├── ICustomerRepository.cs │ ├── IGenericOwnedRepository.cs │ ├── IInvoiceLineItemRepository.cs │ ├── IInvoiceRepository.cs │ ├── IInvoiceTermsRepository.cs │ ├── IRepositoryCollection.cs │ ├── InvoiceLineItemRepository.cs │ ├── InvoiceRepository.cs │ ├── InvoiceTermsRepository.cs │ ├── RepositoryAddException.cs │ ├── RepositoryCollection.cs │ ├── RepositoryDeleteException.cs │ └── RepositoryUpdateException.cs ├── Shared │ ├── LoginDisplay.razor │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css ├── _Imports.razor ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ └── favicon.png ├── BlazorInvoiceAppTests ├── BlazorInvoiceAppTests.csproj ├── GlobalUsings.cs ├── SetupCustomersComponentTests.cs └── UnitTest1.cs └── LICENSE /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/* 381 | !.vscode/settings.json 382 | !.vscode/tasks.json 383 | !.vscode/launch.json 384 | !.vscode/extensions.json 385 | *.code-workspace 386 | 387 | # Local History for Visual Studio Code 388 | .history/ 389 | 390 | # Windows Installer files from build outputs 391 | *.cab 392 | *.msi 393 | *.msix 394 | *.msm 395 | *.msp 396 | 397 | # JetBrains Rider 398 | *.sln.iml 399 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/.cr/personal/FavoritesList/List.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Not found 9 | 10 | Sorry, there's nothing at this address. 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Areas/Identity/Pages/Account/LogOut.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @using Microsoft.AspNetCore.Identity 3 | @attribute [IgnoreAntiforgeryToken] 4 | @inject SignInManager SignInManager 5 | @functions { 6 | public async Task OnPost() 7 | { 8 | if (SignInManager.IsSignedIn(User)) 9 | { 10 | await SignInManager.SignOutAsync(); 11 | } 12 | 13 | return Redirect("~/"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Areas/Identity/Pages/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @inject SignInManager SignInManager 3 | @inject UserManager UserManager 4 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 5 | 6 | 7 | @if (SignInManager.IsSignedIn(User)) 8 | { 9 | 10 | Hello @User.Identity?.Name! 11 | 12 | 13 | 14 | Logout 15 | 16 | 17 | } 18 | else 19 | { 20 | 21 | Register 22 | 23 | 24 | Login 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Areas/Identity/RevalidatingIdentityAuthenticationStateProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.Components.Authorization; 3 | using Microsoft.AspNetCore.Components.Server; 4 | using Microsoft.AspNetCore.Identity; 5 | using Microsoft.Extensions.Options; 6 | using System.Security.Claims; 7 | 8 | namespace BlazorInvoiceApp.Areas.Identity 9 | { 10 | public class RevalidatingIdentityAuthenticationStateProvider 11 | : RevalidatingServerAuthenticationStateProvider where TUser : class 12 | { 13 | private readonly IServiceScopeFactory _scopeFactory; 14 | private readonly IdentityOptions _options; 15 | 16 | public RevalidatingIdentityAuthenticationStateProvider( 17 | ILoggerFactory loggerFactory, 18 | IServiceScopeFactory scopeFactory, 19 | IOptions optionsAccessor) 20 | : base(loggerFactory) 21 | { 22 | _scopeFactory = scopeFactory; 23 | _options = optionsAccessor.Value; 24 | } 25 | 26 | protected override TimeSpan RevalidationInterval => TimeSpan.FromMinutes(30); 27 | 28 | protected override async Task ValidateAuthenticationStateAsync( 29 | AuthenticationState authenticationState, CancellationToken cancellationToken) 30 | { 31 | // Get the user manager from a new scope to ensure it fetches fresh data 32 | var scope = _scopeFactory.CreateScope(); 33 | try 34 | { 35 | var userManager = scope.ServiceProvider.GetRequiredService>(); 36 | return await ValidateSecurityStampAsync(userManager, authenticationState.User); 37 | } 38 | finally 39 | { 40 | if (scope is IAsyncDisposable asyncDisposable) 41 | { 42 | await asyncDisposable.DisposeAsync(); 43 | } 44 | else 45 | { 46 | scope.Dispose(); 47 | } 48 | } 49 | } 50 | 51 | private async Task ValidateSecurityStampAsync(UserManager userManager, ClaimsPrincipal principal) 52 | { 53 | var user = await userManager.GetUserAsync(principal); 54 | if (user == null) 55 | { 56 | return false; 57 | } 58 | else if (!userManager.SupportsUserSecurityStamp) 59 | { 60 | return true; 61 | } 62 | else 63 | { 64 | var principalStamp = principal.FindFirstValue(_options.ClaimsIdentity.SecurityStampClaimType); 65 | var userStamp = await userManager.GetSecurityStampAsync(user); 66 | return principalStamp == userStamp; 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /BlazorInvoiceApp/BlazorInvoiceApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | aspnet-BlazorInvoiceApp-8e925f58-da5d-47fd-9e7c-ff5ca569d2e8 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/BlazorInvoiceApp.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.34031.279 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorInvoiceApp", "BlazorInvoiceApp.csproj", "{04ECF5AC-129F-4728-B7E8-A1F49DEFAB6B}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorInvoiceAppTests", "..\BlazorInvoiceAppTests\BlazorInvoiceAppTests.csproj", "{58379BFD-86CE-4391-B65C-539EF0406048}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {04ECF5AC-129F-4728-B7E8-A1F49DEFAB6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {04ECF5AC-129F-4728-B7E8-A1F49DEFAB6B}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {04ECF5AC-129F-4728-B7E8-A1F49DEFAB6B}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {04ECF5AC-129F-4728-B7E8-A1F49DEFAB6B}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {58379BFD-86CE-4391-B65C-539EF0406048}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {58379BFD-86CE-4391-B65C-539EF0406048}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {58379BFD-86CE-4391-B65C-539EF0406048}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {58379BFD-86CE-4391-B65C-539EF0406048}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {CF5A584D-06CA-435B-8FB3-686BB09CD309} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/DTOS/CustomerDTO.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorInvoiceApp.DTOS 2 | { 3 | public class CustomerDTO : IDTO, IOwnedDTO 4 | { 5 | public string Id { get; set; } = string.Empty; 6 | public string Name { get; set; } = String.Empty; 7 | public string UserId { get; set; } = null!; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/DTOS/IDTO.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorInvoiceApp.DTOS 2 | { 3 | public interface IDTO 4 | { 5 | public string Id { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/DTOS/IOwnedDTO.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorInvoiceApp.DTOS 2 | { 3 | public interface IOwnedDTO 4 | { 5 | public string UserId { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/DTOS/InvoiceDTO.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorInvoiceApp.DTOS 2 | { 3 | public class InvoiceDTO : IDTO, IOwnedDTO 4 | { 5 | public string Id { get; set; } = string.Empty; 6 | public DateTime CreateDate { get; set; } = DateTime.Now; 7 | public int InvoiceNumber { get; set; } 8 | public string Description { get; set; } = string.Empty; 9 | public string CustomerId { get; set; } = string.Empty; 10 | public string CustomerName { get; set; } = string.Empty; 11 | public string InvoiceTermsId { get; set; } = string.Empty; 12 | public string InvoiceTermsName { get; set; } = string.Empty; 13 | public double Paid { get; set; } = 0; 14 | public double Credit { get; set; } = 0; 15 | public double TaxRate { get; set; } = 0; 16 | public double InvoiceTotal { get; set; } = 0; 17 | public string UserId { get; set; } = null!; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/DTOS/InvoiceLineItemDTO.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorInvoiceApp.DTOS 2 | { 3 | public class InvoiceLineItemDTO : IDTO, IOwnedDTO 4 | { 5 | public string Id { get; set; } = Guid.NewGuid().ToString(); 6 | public string InvoiceId { get; set; } = String.Empty; 7 | public string Description { get; set; } = String.Empty; 8 | public double UnitPrice { get; set; } 9 | public double Quantity { get; set; } 10 | public string UserId { get; set; } = null!; 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/DTOS/InvoiceTermsDTO.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorInvoiceApp.DTOS 2 | { 3 | public class InvoiceTermsDTO : IDTO, IOwnedDTO 4 | { 5 | public string Id { get; set; } = string.Empty; 6 | public string Name { get; set; } = String.Empty; 7 | public string UserId { get; set; } = null!; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata; 4 | 5 | namespace BlazorInvoiceApp.Data 6 | { 7 | public class ApplicationDbContext : IdentityDbContext 8 | { 9 | public DbSet Invoices { get; set; } 10 | public DbSet Customers { get; set; } 11 | public DbSet InvoiceTerms { get; set; } 12 | public DbSet InvoicesLineItems { get; set; } 13 | 14 | 15 | public ApplicationDbContext(DbContextOptions options) 16 | : base(options) 17 | { 18 | 19 | 20 | } 21 | 22 | protected void RemoveFixups(ModelBuilder modelBuilder, Type type) 23 | { 24 | foreach (var relationship in modelBuilder.Model.FindEntityType(type)!.GetForeignKeys()) 25 | { 26 | relationship.DeleteBehavior = DeleteBehavior.ClientNoAction; 27 | } 28 | } 29 | 30 | protected override void OnModelCreating(ModelBuilder modelBuilder) 31 | { 32 | // customizations 33 | RemoveFixups(modelBuilder, typeof(Invoice)); 34 | RemoveFixups(modelBuilder, typeof(InvoiceTerms)); 35 | RemoveFixups(modelBuilder, typeof(Customer)); 36 | RemoveFixups(modelBuilder, typeof(InvoiceLineItem)); 37 | 38 | modelBuilder.Entity().Property(u => u.InvoiceNumber).Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); 39 | 40 | modelBuilder.Entity() 41 | .Property(u => u.TotalPrice) 42 | .HasComputedColumnSql("[UnitPrice] * [Quantity]"); 43 | 44 | base.OnModelCreating(modelBuilder); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/Customer.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace BlazorInvoiceApp.Data 5 | { 6 | public class Customer : IEntity, IOwnedEntity 7 | { 8 | [DatabaseGenerated(DatabaseGeneratedOption.None)] 9 | public string Id { get; set; } = Guid.NewGuid().ToString(); 10 | 11 | public string UserId { get; set; } = null!; 12 | public IdentityUser? User { get; set; } = null!; 13 | 14 | 15 | public string Name { get; set; } = String.Empty; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/IEntity.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorInvoiceApp.Data 2 | { 3 | public interface IEntity 4 | { 5 | public string Id { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/IOwnedEntity.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorInvoiceApp.Data 2 | { 3 | public interface IOwnedEntity 4 | { 5 | public string UserId { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/Invoice.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace BlazorInvoiceApp.Data 5 | { 6 | public class Invoice : IEntity, IOwnedEntity 7 | { 8 | [DatabaseGenerated(DatabaseGeneratedOption.None)] 9 | public string Id { get; set; } = Guid.NewGuid().ToString(); 10 | 11 | public string UserId { get; set; } = null!; 12 | public IdentityUser? User { get; set; } = null!; 13 | 14 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 15 | public int InvoiceNumber { get; set; } 16 | 17 | public DateTime CreateDate { get; set; } = DateTime.Now; 18 | 19 | public string Description { get; set; } = String.Empty; 20 | 21 | public string CustomerId { get; set; } = String.Empty; 22 | public Customer? Customer { get; set; } = null!; 23 | 24 | public string InvoiceTermsId { get; set; } = String.Empty; 25 | public InvoiceTerms? InvoiceTerms { get; set; } = null!; 26 | 27 | public double Paid { get; set; } = 0; 28 | public double Credit { get; set; } = 0; 29 | 30 | public double TaxRate { get; set; } = 0; 31 | 32 | public ICollection InvoiceLineItems { get; set; } = new List(); 33 | 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/InvoiceLineItem.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace BlazorInvoiceApp.Data 5 | { 6 | public class InvoiceLineItem : IEntity, IOwnedEntity 7 | { 8 | [DatabaseGenerated(DatabaseGeneratedOption.None)] 9 | public string Id { get; set; } = Guid.NewGuid().ToString(); 10 | 11 | public string InvoiceId { get; set; } = String.Empty; 12 | public Invoice? Invoice { get; set; } = null!; 13 | 14 | public string Description { get; set; } = String.Empty; 15 | public double UnitPrice { get; set; } 16 | public double Quantity { get; set; } 17 | public double TotalPrice { get; private set; } 18 | 19 | public string UserId { get; set; } = null!; 20 | public IdentityUser? User { get; set; } = null!; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/InvoiceTerms.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace BlazorInvoiceApp.Data 5 | { 6 | public class InvoiceTerms : IEntity, IOwnedEntity 7 | { 8 | [DatabaseGenerated(DatabaseGeneratedOption.None)] 9 | public string Id { get; set; } = Guid.NewGuid().ToString(); 10 | 11 | public string UserId { get; set; } = null!; 12 | public IdentityUser? User { get; set; } = null!; 13 | 14 | public string Name { get; set; } = String.Empty; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using BlazorInvoiceApp.Data; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | using System; 9 | 10 | namespace BlazorInvoiceApp.Data.Migrations 11 | { 12 | [DbContext(typeof(ApplicationDbContext))] 13 | [Migration("00000000000000_CreateIdentitySchema")] 14 | partial class CreateIdentitySchema 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "3.0.0") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => 25 | { 26 | b.Property("Id") 27 | .HasColumnType("nvarchar(450)"); 28 | 29 | b.Property("ConcurrencyStamp") 30 | .IsConcurrencyToken() 31 | .HasColumnType("nvarchar(max)"); 32 | 33 | b.Property("Name") 34 | .HasColumnType("nvarchar(256)") 35 | .HasMaxLength(256); 36 | 37 | b.Property("NormalizedName") 38 | .HasColumnType("nvarchar(256)") 39 | .HasMaxLength(256); 40 | 41 | b.HasKey("Id"); 42 | 43 | b.HasIndex("NormalizedName") 44 | .IsUnique() 45 | .HasName("RoleNameIndex") 46 | .HasFilter("[NormalizedName] IS NOT NULL"); 47 | 48 | b.ToTable("AspNetRoles"); 49 | }); 50 | 51 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 52 | { 53 | b.Property("Id") 54 | .ValueGeneratedOnAdd() 55 | .HasColumnType("int") 56 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 57 | 58 | b.Property("ClaimType") 59 | .HasColumnType("nvarchar(max)"); 60 | 61 | b.Property("ClaimValue") 62 | .HasColumnType("nvarchar(max)"); 63 | 64 | b.Property("RoleId") 65 | .IsRequired() 66 | .HasColumnType("nvarchar(450)"); 67 | 68 | b.HasKey("Id"); 69 | 70 | b.HasIndex("RoleId"); 71 | 72 | b.ToTable("AspNetRoleClaims"); 73 | }); 74 | 75 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => 76 | { 77 | b.Property("Id") 78 | .HasColumnType("nvarchar(450)"); 79 | 80 | b.Property("AccessFailedCount") 81 | .HasColumnType("int"); 82 | 83 | b.Property("ConcurrencyStamp") 84 | .IsConcurrencyToken() 85 | .HasColumnType("nvarchar(max)"); 86 | 87 | b.Property("Email") 88 | .HasColumnType("nvarchar(256)") 89 | .HasMaxLength(256); 90 | 91 | b.Property("EmailConfirmed") 92 | .HasColumnType("bit"); 93 | 94 | b.Property("LockoutEnabled") 95 | .HasColumnType("bit"); 96 | 97 | b.Property("LockoutEnd") 98 | .HasColumnType("datetimeoffset"); 99 | 100 | b.Property("NormalizedEmail") 101 | .HasColumnType("nvarchar(256)") 102 | .HasMaxLength(256); 103 | 104 | b.Property("NormalizedUserName") 105 | .HasColumnType("nvarchar(256)") 106 | .HasMaxLength(256); 107 | 108 | b.Property("PasswordHash") 109 | .HasColumnType("nvarchar(max)"); 110 | 111 | b.Property("PhoneNumber") 112 | .HasColumnType("nvarchar(max)"); 113 | 114 | b.Property("PhoneNumberConfirmed") 115 | .HasColumnType("bit"); 116 | 117 | b.Property("SecurityStamp") 118 | .HasColumnType("nvarchar(max)"); 119 | 120 | b.Property("TwoFactorEnabled") 121 | .HasColumnType("bit"); 122 | 123 | b.Property("UserName") 124 | .HasColumnType("nvarchar(256)") 125 | .HasMaxLength(256); 126 | 127 | b.HasKey("Id"); 128 | 129 | b.HasIndex("NormalizedEmail") 130 | .HasName("EmailIndex"); 131 | 132 | b.HasIndex("NormalizedUserName") 133 | .IsUnique() 134 | .HasName("UserNameIndex") 135 | .HasFilter("[NormalizedUserName] IS NOT NULL"); 136 | 137 | b.ToTable("AspNetUsers"); 138 | }); 139 | 140 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 141 | { 142 | b.Property("Id") 143 | .ValueGeneratedOnAdd() 144 | .HasColumnType("int") 145 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 146 | 147 | b.Property("ClaimType") 148 | .HasColumnType("nvarchar(max)"); 149 | 150 | b.Property("ClaimValue") 151 | .HasColumnType("nvarchar(max)"); 152 | 153 | b.Property("UserId") 154 | .IsRequired() 155 | .HasColumnType("nvarchar(450)"); 156 | 157 | b.HasKey("Id"); 158 | 159 | b.HasIndex("UserId"); 160 | 161 | b.ToTable("AspNetUserClaims"); 162 | }); 163 | 164 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 165 | { 166 | b.Property("LoginProvider") 167 | .HasColumnType("nvarchar(128)") 168 | .HasMaxLength(128); 169 | 170 | b.Property("ProviderKey") 171 | .HasColumnType("nvarchar(128)") 172 | .HasMaxLength(128); 173 | 174 | b.Property("ProviderDisplayName") 175 | .HasColumnType("nvarchar(max)"); 176 | 177 | b.Property("UserId") 178 | .IsRequired() 179 | .HasColumnType("nvarchar(450)"); 180 | 181 | b.HasKey("LoginProvider", "ProviderKey"); 182 | 183 | b.HasIndex("UserId"); 184 | 185 | b.ToTable("AspNetUserLogins"); 186 | }); 187 | 188 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 189 | { 190 | b.Property("UserId") 191 | .HasColumnType("nvarchar(450)"); 192 | 193 | b.Property("RoleId") 194 | .HasColumnType("nvarchar(450)"); 195 | 196 | b.HasKey("UserId", "RoleId"); 197 | 198 | b.HasIndex("RoleId"); 199 | 200 | b.ToTable("AspNetUserRoles"); 201 | }); 202 | 203 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 204 | { 205 | b.Property("UserId") 206 | .HasColumnType("nvarchar(450)"); 207 | 208 | b.Property("LoginProvider") 209 | .HasColumnType("nvarchar(128)") 210 | .HasMaxLength(128); 211 | 212 | b.Property("Name") 213 | .HasColumnType("nvarchar(128)") 214 | .HasMaxLength(128); 215 | 216 | b.Property("Value") 217 | .HasColumnType("nvarchar(max)"); 218 | 219 | b.HasKey("UserId", "LoginProvider", "Name"); 220 | 221 | b.ToTable("AspNetUserTokens"); 222 | }); 223 | 224 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 225 | { 226 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 227 | .WithMany() 228 | .HasForeignKey("RoleId") 229 | .OnDelete(DeleteBehavior.Cascade) 230 | .IsRequired(); 231 | }); 232 | 233 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 234 | { 235 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) 236 | .WithMany() 237 | .HasForeignKey("UserId") 238 | .OnDelete(DeleteBehavior.Cascade) 239 | .IsRequired(); 240 | }); 241 | 242 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 243 | { 244 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) 245 | .WithMany() 246 | .HasForeignKey("UserId") 247 | .OnDelete(DeleteBehavior.Cascade) 248 | .IsRequired(); 249 | }); 250 | 251 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 252 | { 253 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 254 | .WithMany() 255 | .HasForeignKey("RoleId") 256 | .OnDelete(DeleteBehavior.Cascade) 257 | .IsRequired(); 258 | 259 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) 260 | .WithMany() 261 | .HasForeignKey("UserId") 262 | .OnDelete(DeleteBehavior.Cascade) 263 | .IsRequired(); 264 | }); 265 | 266 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 267 | { 268 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) 269 | .WithMany() 270 | .HasForeignKey("UserId") 271 | .OnDelete(DeleteBehavior.Cascade) 272 | .IsRequired(); 273 | }); 274 | #pragma warning restore 612, 618 275 | } 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/Migrations/00000000000000_CreateIdentitySchema.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Metadata; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | using System; 4 | 5 | namespace BlazorInvoiceApp.Data.Migrations 6 | { 7 | public partial class CreateIdentitySchema : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.CreateTable( 12 | name: "AspNetRoles", 13 | columns: table => new 14 | { 15 | Id = table.Column(nullable: false), 16 | Name = table.Column(maxLength: 256, nullable: true), 17 | NormalizedName = table.Column(maxLength: 256, nullable: true), 18 | ConcurrencyStamp = table.Column(nullable: true) 19 | }, 20 | constraints: table => 21 | { 22 | table.PrimaryKey("PK_AspNetRoles", x => x.Id); 23 | }); 24 | 25 | migrationBuilder.CreateTable( 26 | name: "AspNetUsers", 27 | columns: table => new 28 | { 29 | Id = table.Column(nullable: false), 30 | UserName = table.Column(maxLength: 256, nullable: true), 31 | NormalizedUserName = table.Column(maxLength: 256, nullable: true), 32 | Email = table.Column(maxLength: 256, nullable: true), 33 | NormalizedEmail = table.Column(maxLength: 256, nullable: true), 34 | EmailConfirmed = table.Column(nullable: false), 35 | PasswordHash = table.Column(nullable: true), 36 | SecurityStamp = table.Column(nullable: true), 37 | ConcurrencyStamp = table.Column(nullable: true), 38 | PhoneNumber = table.Column(nullable: true), 39 | PhoneNumberConfirmed = table.Column(nullable: false), 40 | TwoFactorEnabled = table.Column(nullable: false), 41 | LockoutEnd = table.Column(nullable: true), 42 | LockoutEnabled = table.Column(nullable: false), 43 | AccessFailedCount = table.Column(nullable: false) 44 | }, 45 | constraints: table => 46 | { 47 | table.PrimaryKey("PK_AspNetUsers", x => x.Id); 48 | }); 49 | 50 | migrationBuilder.CreateTable( 51 | name: "AspNetRoleClaims", 52 | columns: table => new 53 | { 54 | Id = table.Column(nullable: false) 55 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), 56 | RoleId = table.Column(nullable: false), 57 | ClaimType = table.Column(nullable: true), 58 | ClaimValue = table.Column(nullable: true) 59 | }, 60 | constraints: table => 61 | { 62 | table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); 63 | table.ForeignKey( 64 | name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", 65 | column: x => x.RoleId, 66 | principalTable: "AspNetRoles", 67 | principalColumn: "Id", 68 | onDelete: ReferentialAction.Cascade); 69 | }); 70 | 71 | migrationBuilder.CreateTable( 72 | name: "AspNetUserClaims", 73 | columns: table => new 74 | { 75 | Id = table.Column(nullable: false) 76 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), 77 | UserId = table.Column(nullable: false), 78 | ClaimType = table.Column(nullable: true), 79 | ClaimValue = table.Column(nullable: true) 80 | }, 81 | constraints: table => 82 | { 83 | table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); 84 | table.ForeignKey( 85 | name: "FK_AspNetUserClaims_AspNetUsers_UserId", 86 | column: x => x.UserId, 87 | principalTable: "AspNetUsers", 88 | principalColumn: "Id", 89 | onDelete: ReferentialAction.Cascade); 90 | }); 91 | 92 | migrationBuilder.CreateTable( 93 | name: "AspNetUserLogins", 94 | columns: table => new 95 | { 96 | LoginProvider = table.Column(maxLength: 128, nullable: false), 97 | ProviderKey = table.Column(maxLength: 128, nullable: false), 98 | ProviderDisplayName = table.Column(nullable: true), 99 | UserId = table.Column(nullable: false) 100 | }, 101 | constraints: table => 102 | { 103 | table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); 104 | table.ForeignKey( 105 | name: "FK_AspNetUserLogins_AspNetUsers_UserId", 106 | column: x => x.UserId, 107 | principalTable: "AspNetUsers", 108 | principalColumn: "Id", 109 | onDelete: ReferentialAction.Cascade); 110 | }); 111 | 112 | migrationBuilder.CreateTable( 113 | name: "AspNetUserRoles", 114 | columns: table => new 115 | { 116 | UserId = table.Column(nullable: false), 117 | RoleId = table.Column(nullable: false) 118 | }, 119 | constraints: table => 120 | { 121 | table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); 122 | table.ForeignKey( 123 | name: "FK_AspNetUserRoles_AspNetRoles_RoleId", 124 | column: x => x.RoleId, 125 | principalTable: "AspNetRoles", 126 | principalColumn: "Id", 127 | onDelete: ReferentialAction.Cascade); 128 | table.ForeignKey( 129 | name: "FK_AspNetUserRoles_AspNetUsers_UserId", 130 | column: x => x.UserId, 131 | principalTable: "AspNetUsers", 132 | principalColumn: "Id", 133 | onDelete: ReferentialAction.Cascade); 134 | }); 135 | 136 | migrationBuilder.CreateTable( 137 | name: "AspNetUserTokens", 138 | columns: table => new 139 | { 140 | UserId = table.Column(nullable: false), 141 | LoginProvider = table.Column(maxLength: 128, nullable: false), 142 | Name = table.Column(maxLength: 128, nullable: false), 143 | Value = table.Column(nullable: true) 144 | }, 145 | constraints: table => 146 | { 147 | table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); 148 | table.ForeignKey( 149 | name: "FK_AspNetUserTokens_AspNetUsers_UserId", 150 | column: x => x.UserId, 151 | principalTable: "AspNetUsers", 152 | principalColumn: "Id", 153 | onDelete: ReferentialAction.Cascade); 154 | }); 155 | 156 | migrationBuilder.CreateIndex( 157 | name: "IX_AspNetRoleClaims_RoleId", 158 | table: "AspNetRoleClaims", 159 | column: "RoleId"); 160 | 161 | migrationBuilder.CreateIndex( 162 | name: "RoleNameIndex", 163 | table: "AspNetRoles", 164 | column: "NormalizedName", 165 | unique: true, 166 | filter: "[NormalizedName] IS NOT NULL"); 167 | 168 | migrationBuilder.CreateIndex( 169 | name: "IX_AspNetUserClaims_UserId", 170 | table: "AspNetUserClaims", 171 | column: "UserId"); 172 | 173 | migrationBuilder.CreateIndex( 174 | name: "IX_AspNetUserLogins_UserId", 175 | table: "AspNetUserLogins", 176 | column: "UserId"); 177 | 178 | migrationBuilder.CreateIndex( 179 | name: "IX_AspNetUserRoles_RoleId", 180 | table: "AspNetUserRoles", 181 | column: "RoleId"); 182 | 183 | migrationBuilder.CreateIndex( 184 | name: "EmailIndex", 185 | table: "AspNetUsers", 186 | column: "NormalizedEmail"); 187 | 188 | migrationBuilder.CreateIndex( 189 | name: "UserNameIndex", 190 | table: "AspNetUsers", 191 | column: "NormalizedUserName", 192 | unique: true, 193 | filter: "[NormalizedUserName] IS NOT NULL"); 194 | } 195 | 196 | protected override void Down(MigrationBuilder migrationBuilder) 197 | { 198 | migrationBuilder.DropTable( 199 | name: "AspNetRoleClaims"); 200 | 201 | migrationBuilder.DropTable( 202 | name: "AspNetUserClaims"); 203 | 204 | migrationBuilder.DropTable( 205 | name: "AspNetUserLogins"); 206 | 207 | migrationBuilder.DropTable( 208 | name: "AspNetUserRoles"); 209 | 210 | migrationBuilder.DropTable( 211 | name: "AspNetUserTokens"); 212 | 213 | migrationBuilder.DropTable( 214 | name: "AspNetRoles"); 215 | 216 | migrationBuilder.DropTable( 217 | name: "AspNetUsers"); 218 | } 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/Migrations/20230926013249_db1.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using BlazorInvoiceApp.Data; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Microsoft.EntityFrameworkCore.Migrations; 8 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 9 | 10 | #nullable disable 11 | 12 | namespace BlazorInvoiceApp.Data.Migrations 13 | { 14 | [DbContext(typeof(ApplicationDbContext))] 15 | [Migration("20230926013249_db1")] 16 | partial class db1 17 | { 18 | /// 19 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 20 | { 21 | #pragma warning disable 612, 618 22 | modelBuilder 23 | .HasAnnotation("ProductVersion", "7.0.11") 24 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 25 | 26 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); 27 | 28 | modelBuilder.Entity("BlazorInvoiceApp.Data.Customer", b => 29 | { 30 | b.Property("Id") 31 | .HasColumnType("nvarchar(450)"); 32 | 33 | b.Property("Name") 34 | .IsRequired() 35 | .HasColumnType("nvarchar(max)"); 36 | 37 | b.Property("UserId") 38 | .IsRequired() 39 | .HasColumnType("nvarchar(450)"); 40 | 41 | b.HasKey("Id"); 42 | 43 | b.HasIndex("UserId"); 44 | 45 | b.ToTable("Customers"); 46 | }); 47 | 48 | modelBuilder.Entity("BlazorInvoiceApp.Data.Invoice", b => 49 | { 50 | b.Property("Id") 51 | .HasColumnType("nvarchar(450)"); 52 | 53 | b.Property("CreateDate") 54 | .HasColumnType("datetime2"); 55 | 56 | b.Property("Credit") 57 | .HasColumnType("float"); 58 | 59 | b.Property("CustomerId") 60 | .IsRequired() 61 | .HasColumnType("nvarchar(450)"); 62 | 63 | b.Property("Description") 64 | .IsRequired() 65 | .HasColumnType("nvarchar(max)"); 66 | 67 | b.Property("InvoiceNumber") 68 | .ValueGeneratedOnAdd() 69 | .HasColumnType("int"); 70 | 71 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InvoiceNumber")); 72 | 73 | b.Property("InvoiceTermsId") 74 | .IsRequired() 75 | .HasColumnType("nvarchar(450)"); 76 | 77 | b.Property("Paid") 78 | .HasColumnType("float"); 79 | 80 | b.Property("TaxRate") 81 | .HasColumnType("float"); 82 | 83 | b.Property("UserId") 84 | .IsRequired() 85 | .HasColumnType("nvarchar(450)"); 86 | 87 | b.HasKey("Id"); 88 | 89 | b.HasIndex("CustomerId"); 90 | 91 | b.HasIndex("InvoiceTermsId"); 92 | 93 | b.HasIndex("UserId"); 94 | 95 | b.ToTable("Invoices"); 96 | }); 97 | 98 | modelBuilder.Entity("BlazorInvoiceApp.Data.InvoiceLineItem", b => 99 | { 100 | b.Property("Id") 101 | .HasColumnType("nvarchar(450)"); 102 | 103 | b.Property("Description") 104 | .IsRequired() 105 | .HasColumnType("nvarchar(max)"); 106 | 107 | b.Property("InvoiceId") 108 | .IsRequired() 109 | .HasColumnType("nvarchar(450)"); 110 | 111 | b.Property("Quantity") 112 | .HasColumnType("float"); 113 | 114 | b.Property("TotalPrice") 115 | .ValueGeneratedOnAddOrUpdate() 116 | .HasColumnType("float") 117 | .HasComputedColumnSql("[UnitPrice] * [Quantity]"); 118 | 119 | b.Property("UnitPrice") 120 | .HasColumnType("float"); 121 | 122 | b.Property("UserId") 123 | .IsRequired() 124 | .HasColumnType("nvarchar(450)"); 125 | 126 | b.HasKey("Id"); 127 | 128 | b.HasIndex("InvoiceId"); 129 | 130 | b.HasIndex("UserId"); 131 | 132 | b.ToTable("InvoicesLineItems"); 133 | }); 134 | 135 | modelBuilder.Entity("BlazorInvoiceApp.Data.InvoiceTerms", b => 136 | { 137 | b.Property("Id") 138 | .HasColumnType("nvarchar(450)"); 139 | 140 | b.Property("Name") 141 | .IsRequired() 142 | .HasColumnType("nvarchar(max)"); 143 | 144 | b.Property("UserId") 145 | .IsRequired() 146 | .HasColumnType("nvarchar(450)"); 147 | 148 | b.HasKey("Id"); 149 | 150 | b.HasIndex("UserId"); 151 | 152 | b.ToTable("InvoiceTerms"); 153 | }); 154 | 155 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => 156 | { 157 | b.Property("Id") 158 | .HasColumnType("nvarchar(450)"); 159 | 160 | b.Property("ConcurrencyStamp") 161 | .IsConcurrencyToken() 162 | .HasColumnType("nvarchar(max)"); 163 | 164 | b.Property("Name") 165 | .HasMaxLength(256) 166 | .HasColumnType("nvarchar(256)"); 167 | 168 | b.Property("NormalizedName") 169 | .HasMaxLength(256) 170 | .HasColumnType("nvarchar(256)"); 171 | 172 | b.HasKey("Id"); 173 | 174 | b.HasIndex("NormalizedName") 175 | .IsUnique() 176 | .HasDatabaseName("RoleNameIndex") 177 | .HasFilter("[NormalizedName] IS NOT NULL"); 178 | 179 | b.ToTable("AspNetRoles", (string)null); 180 | }); 181 | 182 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 183 | { 184 | b.Property("Id") 185 | .ValueGeneratedOnAdd() 186 | .HasColumnType("int"); 187 | 188 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 189 | 190 | b.Property("ClaimType") 191 | .HasColumnType("nvarchar(max)"); 192 | 193 | b.Property("ClaimValue") 194 | .HasColumnType("nvarchar(max)"); 195 | 196 | b.Property("RoleId") 197 | .IsRequired() 198 | .HasColumnType("nvarchar(450)"); 199 | 200 | b.HasKey("Id"); 201 | 202 | b.HasIndex("RoleId"); 203 | 204 | b.ToTable("AspNetRoleClaims", (string)null); 205 | }); 206 | 207 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => 208 | { 209 | b.Property("Id") 210 | .HasColumnType("nvarchar(450)"); 211 | 212 | b.Property("AccessFailedCount") 213 | .HasColumnType("int"); 214 | 215 | b.Property("ConcurrencyStamp") 216 | .IsConcurrencyToken() 217 | .HasColumnType("nvarchar(max)"); 218 | 219 | b.Property("Email") 220 | .HasMaxLength(256) 221 | .HasColumnType("nvarchar(256)"); 222 | 223 | b.Property("EmailConfirmed") 224 | .HasColumnType("bit"); 225 | 226 | b.Property("LockoutEnabled") 227 | .HasColumnType("bit"); 228 | 229 | b.Property("LockoutEnd") 230 | .HasColumnType("datetimeoffset"); 231 | 232 | b.Property("NormalizedEmail") 233 | .HasMaxLength(256) 234 | .HasColumnType("nvarchar(256)"); 235 | 236 | b.Property("NormalizedUserName") 237 | .HasMaxLength(256) 238 | .HasColumnType("nvarchar(256)"); 239 | 240 | b.Property("PasswordHash") 241 | .HasColumnType("nvarchar(max)"); 242 | 243 | b.Property("PhoneNumber") 244 | .HasColumnType("nvarchar(max)"); 245 | 246 | b.Property("PhoneNumberConfirmed") 247 | .HasColumnType("bit"); 248 | 249 | b.Property("SecurityStamp") 250 | .HasColumnType("nvarchar(max)"); 251 | 252 | b.Property("TwoFactorEnabled") 253 | .HasColumnType("bit"); 254 | 255 | b.Property("UserName") 256 | .HasMaxLength(256) 257 | .HasColumnType("nvarchar(256)"); 258 | 259 | b.HasKey("Id"); 260 | 261 | b.HasIndex("NormalizedEmail") 262 | .HasDatabaseName("EmailIndex"); 263 | 264 | b.HasIndex("NormalizedUserName") 265 | .IsUnique() 266 | .HasDatabaseName("UserNameIndex") 267 | .HasFilter("[NormalizedUserName] IS NOT NULL"); 268 | 269 | b.ToTable("AspNetUsers", (string)null); 270 | }); 271 | 272 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 273 | { 274 | b.Property("Id") 275 | .ValueGeneratedOnAdd() 276 | .HasColumnType("int"); 277 | 278 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 279 | 280 | b.Property("ClaimType") 281 | .HasColumnType("nvarchar(max)"); 282 | 283 | b.Property("ClaimValue") 284 | .HasColumnType("nvarchar(max)"); 285 | 286 | b.Property("UserId") 287 | .IsRequired() 288 | .HasColumnType("nvarchar(450)"); 289 | 290 | b.HasKey("Id"); 291 | 292 | b.HasIndex("UserId"); 293 | 294 | b.ToTable("AspNetUserClaims", (string)null); 295 | }); 296 | 297 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 298 | { 299 | b.Property("LoginProvider") 300 | .HasMaxLength(128) 301 | .HasColumnType("nvarchar(128)"); 302 | 303 | b.Property("ProviderKey") 304 | .HasMaxLength(128) 305 | .HasColumnType("nvarchar(128)"); 306 | 307 | b.Property("ProviderDisplayName") 308 | .HasColumnType("nvarchar(max)"); 309 | 310 | b.Property("UserId") 311 | .IsRequired() 312 | .HasColumnType("nvarchar(450)"); 313 | 314 | b.HasKey("LoginProvider", "ProviderKey"); 315 | 316 | b.HasIndex("UserId"); 317 | 318 | b.ToTable("AspNetUserLogins", (string)null); 319 | }); 320 | 321 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 322 | { 323 | b.Property("UserId") 324 | .HasColumnType("nvarchar(450)"); 325 | 326 | b.Property("RoleId") 327 | .HasColumnType("nvarchar(450)"); 328 | 329 | b.HasKey("UserId", "RoleId"); 330 | 331 | b.HasIndex("RoleId"); 332 | 333 | b.ToTable("AspNetUserRoles", (string)null); 334 | }); 335 | 336 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 337 | { 338 | b.Property("UserId") 339 | .HasColumnType("nvarchar(450)"); 340 | 341 | b.Property("LoginProvider") 342 | .HasMaxLength(128) 343 | .HasColumnType("nvarchar(128)"); 344 | 345 | b.Property("Name") 346 | .HasMaxLength(128) 347 | .HasColumnType("nvarchar(128)"); 348 | 349 | b.Property("Value") 350 | .HasColumnType("nvarchar(max)"); 351 | 352 | b.HasKey("UserId", "LoginProvider", "Name"); 353 | 354 | b.ToTable("AspNetUserTokens", (string)null); 355 | }); 356 | 357 | modelBuilder.Entity("BlazorInvoiceApp.Data.Customer", b => 358 | { 359 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") 360 | .WithMany() 361 | .HasForeignKey("UserId") 362 | .OnDelete(DeleteBehavior.ClientNoAction) 363 | .IsRequired(); 364 | 365 | b.Navigation("User"); 366 | }); 367 | 368 | modelBuilder.Entity("BlazorInvoiceApp.Data.Invoice", b => 369 | { 370 | b.HasOne("BlazorInvoiceApp.Data.Customer", "Customer") 371 | .WithMany() 372 | .HasForeignKey("CustomerId") 373 | .OnDelete(DeleteBehavior.ClientNoAction) 374 | .IsRequired(); 375 | 376 | b.HasOne("BlazorInvoiceApp.Data.InvoiceTerms", "InvoiceTerms") 377 | .WithMany() 378 | .HasForeignKey("InvoiceTermsId") 379 | .OnDelete(DeleteBehavior.ClientNoAction) 380 | .IsRequired(); 381 | 382 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") 383 | .WithMany() 384 | .HasForeignKey("UserId") 385 | .OnDelete(DeleteBehavior.ClientNoAction) 386 | .IsRequired(); 387 | 388 | b.Navigation("Customer"); 389 | 390 | b.Navigation("InvoiceTerms"); 391 | 392 | b.Navigation("User"); 393 | }); 394 | 395 | modelBuilder.Entity("BlazorInvoiceApp.Data.InvoiceLineItem", b => 396 | { 397 | b.HasOne("BlazorInvoiceApp.Data.Invoice", "Invoice") 398 | .WithMany("InvoiceLineItems") 399 | .HasForeignKey("InvoiceId") 400 | .OnDelete(DeleteBehavior.ClientNoAction) 401 | .IsRequired(); 402 | 403 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") 404 | .WithMany() 405 | .HasForeignKey("UserId") 406 | .OnDelete(DeleteBehavior.ClientNoAction) 407 | .IsRequired(); 408 | 409 | b.Navigation("Invoice"); 410 | 411 | b.Navigation("User"); 412 | }); 413 | 414 | modelBuilder.Entity("BlazorInvoiceApp.Data.InvoiceTerms", b => 415 | { 416 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") 417 | .WithMany() 418 | .HasForeignKey("UserId") 419 | .OnDelete(DeleteBehavior.ClientNoAction) 420 | .IsRequired(); 421 | 422 | b.Navigation("User"); 423 | }); 424 | 425 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 426 | { 427 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 428 | .WithMany() 429 | .HasForeignKey("RoleId") 430 | .OnDelete(DeleteBehavior.Cascade) 431 | .IsRequired(); 432 | }); 433 | 434 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 435 | { 436 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) 437 | .WithMany() 438 | .HasForeignKey("UserId") 439 | .OnDelete(DeleteBehavior.Cascade) 440 | .IsRequired(); 441 | }); 442 | 443 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 444 | { 445 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) 446 | .WithMany() 447 | .HasForeignKey("UserId") 448 | .OnDelete(DeleteBehavior.Cascade) 449 | .IsRequired(); 450 | }); 451 | 452 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 453 | { 454 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 455 | .WithMany() 456 | .HasForeignKey("RoleId") 457 | .OnDelete(DeleteBehavior.Cascade) 458 | .IsRequired(); 459 | 460 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) 461 | .WithMany() 462 | .HasForeignKey("UserId") 463 | .OnDelete(DeleteBehavior.Cascade) 464 | .IsRequired(); 465 | }); 466 | 467 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 468 | { 469 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) 470 | .WithMany() 471 | .HasForeignKey("UserId") 472 | .OnDelete(DeleteBehavior.Cascade) 473 | .IsRequired(); 474 | }); 475 | 476 | modelBuilder.Entity("BlazorInvoiceApp.Data.Invoice", b => 477 | { 478 | b.Navigation("InvoiceLineItems"); 479 | }); 480 | #pragma warning restore 612, 618 481 | } 482 | } 483 | } 484 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/Migrations/20230926013249_db1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | #nullable disable 5 | 6 | namespace BlazorInvoiceApp.Data.Migrations 7 | { 8 | /// 9 | public partial class db1 : Migration 10 | { 11 | /// 12 | protected override void Up(MigrationBuilder migrationBuilder) 13 | { 14 | migrationBuilder.CreateTable( 15 | name: "Customers", 16 | columns: table => new 17 | { 18 | Id = table.Column(type: "nvarchar(450)", nullable: false), 19 | UserId = table.Column(type: "nvarchar(450)", nullable: false), 20 | Name = table.Column(type: "nvarchar(max)", nullable: false) 21 | }, 22 | constraints: table => 23 | { 24 | table.PrimaryKey("PK_Customers", x => x.Id); 25 | table.ForeignKey( 26 | name: "FK_Customers_AspNetUsers_UserId", 27 | column: x => x.UserId, 28 | principalTable: "AspNetUsers", 29 | principalColumn: "Id"); 30 | }); 31 | 32 | migrationBuilder.CreateTable( 33 | name: "InvoiceTerms", 34 | columns: table => new 35 | { 36 | Id = table.Column(type: "nvarchar(450)", nullable: false), 37 | UserId = table.Column(type: "nvarchar(450)", nullable: false), 38 | Name = table.Column(type: "nvarchar(max)", nullable: false) 39 | }, 40 | constraints: table => 41 | { 42 | table.PrimaryKey("PK_InvoiceTerms", x => x.Id); 43 | table.ForeignKey( 44 | name: "FK_InvoiceTerms_AspNetUsers_UserId", 45 | column: x => x.UserId, 46 | principalTable: "AspNetUsers", 47 | principalColumn: "Id"); 48 | }); 49 | 50 | migrationBuilder.CreateTable( 51 | name: "Invoices", 52 | columns: table => new 53 | { 54 | Id = table.Column(type: "nvarchar(450)", nullable: false), 55 | UserId = table.Column(type: "nvarchar(450)", nullable: false), 56 | InvoiceNumber = table.Column(type: "int", nullable: false) 57 | .Annotation("SqlServer:Identity", "1, 1"), 58 | CreateDate = table.Column(type: "datetime2", nullable: false), 59 | Description = table.Column(type: "nvarchar(max)", nullable: false), 60 | CustomerId = table.Column(type: "nvarchar(450)", nullable: false), 61 | InvoiceTermsId = table.Column(type: "nvarchar(450)", nullable: false), 62 | Paid = table.Column(type: "float", nullable: false), 63 | Credit = table.Column(type: "float", nullable: false), 64 | TaxRate = table.Column(type: "float", nullable: false) 65 | }, 66 | constraints: table => 67 | { 68 | table.PrimaryKey("PK_Invoices", x => x.Id); 69 | table.ForeignKey( 70 | name: "FK_Invoices_AspNetUsers_UserId", 71 | column: x => x.UserId, 72 | principalTable: "AspNetUsers", 73 | principalColumn: "Id"); 74 | table.ForeignKey( 75 | name: "FK_Invoices_Customers_CustomerId", 76 | column: x => x.CustomerId, 77 | principalTable: "Customers", 78 | principalColumn: "Id"); 79 | table.ForeignKey( 80 | name: "FK_Invoices_InvoiceTerms_InvoiceTermsId", 81 | column: x => x.InvoiceTermsId, 82 | principalTable: "InvoiceTerms", 83 | principalColumn: "Id"); 84 | }); 85 | 86 | migrationBuilder.CreateTable( 87 | name: "InvoicesLineItems", 88 | columns: table => new 89 | { 90 | Id = table.Column(type: "nvarchar(450)", nullable: false), 91 | InvoiceId = table.Column(type: "nvarchar(450)", nullable: false), 92 | Description = table.Column(type: "nvarchar(max)", nullable: false), 93 | UnitPrice = table.Column(type: "float", nullable: false), 94 | Quantity = table.Column(type: "float", nullable: false), 95 | TotalPrice = table.Column(type: "float", nullable: false, computedColumnSql: "[UnitPrice] * [Quantity]"), 96 | UserId = table.Column(type: "nvarchar(450)", nullable: false) 97 | }, 98 | constraints: table => 99 | { 100 | table.PrimaryKey("PK_InvoicesLineItems", x => x.Id); 101 | table.ForeignKey( 102 | name: "FK_InvoicesLineItems_AspNetUsers_UserId", 103 | column: x => x.UserId, 104 | principalTable: "AspNetUsers", 105 | principalColumn: "Id"); 106 | table.ForeignKey( 107 | name: "FK_InvoicesLineItems_Invoices_InvoiceId", 108 | column: x => x.InvoiceId, 109 | principalTable: "Invoices", 110 | principalColumn: "Id"); 111 | }); 112 | 113 | migrationBuilder.CreateIndex( 114 | name: "IX_Customers_UserId", 115 | table: "Customers", 116 | column: "UserId"); 117 | 118 | migrationBuilder.CreateIndex( 119 | name: "IX_Invoices_CustomerId", 120 | table: "Invoices", 121 | column: "CustomerId"); 122 | 123 | migrationBuilder.CreateIndex( 124 | name: "IX_Invoices_InvoiceTermsId", 125 | table: "Invoices", 126 | column: "InvoiceTermsId"); 127 | 128 | migrationBuilder.CreateIndex( 129 | name: "IX_Invoices_UserId", 130 | table: "Invoices", 131 | column: "UserId"); 132 | 133 | migrationBuilder.CreateIndex( 134 | name: "IX_InvoicesLineItems_InvoiceId", 135 | table: "InvoicesLineItems", 136 | column: "InvoiceId"); 137 | 138 | migrationBuilder.CreateIndex( 139 | name: "IX_InvoicesLineItems_UserId", 140 | table: "InvoicesLineItems", 141 | column: "UserId"); 142 | 143 | migrationBuilder.CreateIndex( 144 | name: "IX_InvoiceTerms_UserId", 145 | table: "InvoiceTerms", 146 | column: "UserId"); 147 | } 148 | 149 | /// 150 | protected override void Down(MigrationBuilder migrationBuilder) 151 | { 152 | migrationBuilder.DropTable( 153 | name: "InvoicesLineItems"); 154 | 155 | migrationBuilder.DropTable( 156 | name: "Invoices"); 157 | 158 | migrationBuilder.DropTable( 159 | name: "Customers"); 160 | 161 | migrationBuilder.DropTable( 162 | name: "InvoiceTerms"); 163 | } 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /BlazorInvoiceApp/Data/Migrations/ApplicationDbContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using BlazorInvoiceApp.Data; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | 9 | #nullable disable 10 | 11 | namespace BlazorInvoiceApp.Data.Migrations 12 | { 13 | [DbContext(typeof(ApplicationDbContext))] 14 | partial class ApplicationDbContextModelSnapshot : ModelSnapshot 15 | { 16 | protected override void BuildModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "7.0.11") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 22 | 23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); 24 | 25 | modelBuilder.Entity("BlazorInvoiceApp.Data.Customer", b => 26 | { 27 | b.Property("Id") 28 | .HasColumnType("nvarchar(450)"); 29 | 30 | b.Property("Name") 31 | .IsRequired() 32 | .HasColumnType("nvarchar(max)"); 33 | 34 | b.Property("UserId") 35 | .IsRequired() 36 | .HasColumnType("nvarchar(450)"); 37 | 38 | b.HasKey("Id"); 39 | 40 | b.HasIndex("UserId"); 41 | 42 | b.ToTable("Customers"); 43 | }); 44 | 45 | modelBuilder.Entity("BlazorInvoiceApp.Data.Invoice", b => 46 | { 47 | b.Property("Id") 48 | .HasColumnType("nvarchar(450)"); 49 | 50 | b.Property("CreateDate") 51 | .HasColumnType("datetime2"); 52 | 53 | b.Property("Credit") 54 | .HasColumnType("float"); 55 | 56 | b.Property("CustomerId") 57 | .IsRequired() 58 | .HasColumnType("nvarchar(450)"); 59 | 60 | b.Property("Description") 61 | .IsRequired() 62 | .HasColumnType("nvarchar(max)"); 63 | 64 | b.Property("InvoiceNumber") 65 | .ValueGeneratedOnAdd() 66 | .HasColumnType("int"); 67 | 68 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InvoiceNumber")); 69 | 70 | b.Property("InvoiceTermsId") 71 | .IsRequired() 72 | .HasColumnType("nvarchar(450)"); 73 | 74 | b.Property("Paid") 75 | .HasColumnType("float"); 76 | 77 | b.Property("TaxRate") 78 | .HasColumnType("float"); 79 | 80 | b.Property("UserId") 81 | .IsRequired() 82 | .HasColumnType("nvarchar(450)"); 83 | 84 | b.HasKey("Id"); 85 | 86 | b.HasIndex("CustomerId"); 87 | 88 | b.HasIndex("InvoiceTermsId"); 89 | 90 | b.HasIndex("UserId"); 91 | 92 | b.ToTable("Invoices"); 93 | }); 94 | 95 | modelBuilder.Entity("BlazorInvoiceApp.Data.InvoiceLineItem", b => 96 | { 97 | b.Property("Id") 98 | .HasColumnType("nvarchar(450)"); 99 | 100 | b.Property("Description") 101 | .IsRequired() 102 | .HasColumnType("nvarchar(max)"); 103 | 104 | b.Property("InvoiceId") 105 | .IsRequired() 106 | .HasColumnType("nvarchar(450)"); 107 | 108 | b.Property("Quantity") 109 | .HasColumnType("float"); 110 | 111 | b.Property("TotalPrice") 112 | .ValueGeneratedOnAddOrUpdate() 113 | .HasColumnType("float") 114 | .HasComputedColumnSql("[UnitPrice] * [Quantity]"); 115 | 116 | b.Property("UnitPrice") 117 | .HasColumnType("float"); 118 | 119 | b.Property("UserId") 120 | .IsRequired() 121 | .HasColumnType("nvarchar(450)"); 122 | 123 | b.HasKey("Id"); 124 | 125 | b.HasIndex("InvoiceId"); 126 | 127 | b.HasIndex("UserId"); 128 | 129 | b.ToTable("InvoicesLineItems"); 130 | }); 131 | 132 | modelBuilder.Entity("BlazorInvoiceApp.Data.InvoiceTerms", b => 133 | { 134 | b.Property("Id") 135 | .HasColumnType("nvarchar(450)"); 136 | 137 | b.Property("Name") 138 | .IsRequired() 139 | .HasColumnType("nvarchar(max)"); 140 | 141 | b.Property("UserId") 142 | .IsRequired() 143 | .HasColumnType("nvarchar(450)"); 144 | 145 | b.HasKey("Id"); 146 | 147 | b.HasIndex("UserId"); 148 | 149 | b.ToTable("InvoiceTerms"); 150 | }); 151 | 152 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => 153 | { 154 | b.Property("Id") 155 | .HasColumnType("nvarchar(450)"); 156 | 157 | b.Property("ConcurrencyStamp") 158 | .IsConcurrencyToken() 159 | .HasColumnType("nvarchar(max)"); 160 | 161 | b.Property("Name") 162 | .HasMaxLength(256) 163 | .HasColumnType("nvarchar(256)"); 164 | 165 | b.Property("NormalizedName") 166 | .HasMaxLength(256) 167 | .HasColumnType("nvarchar(256)"); 168 | 169 | b.HasKey("Id"); 170 | 171 | b.HasIndex("NormalizedName") 172 | .IsUnique() 173 | .HasDatabaseName("RoleNameIndex") 174 | .HasFilter("[NormalizedName] IS NOT NULL"); 175 | 176 | b.ToTable("AspNetRoles", (string)null); 177 | }); 178 | 179 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 180 | { 181 | b.Property("Id") 182 | .ValueGeneratedOnAdd() 183 | .HasColumnType("int"); 184 | 185 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 186 | 187 | b.Property("ClaimType") 188 | .HasColumnType("nvarchar(max)"); 189 | 190 | b.Property("ClaimValue") 191 | .HasColumnType("nvarchar(max)"); 192 | 193 | b.Property("RoleId") 194 | .IsRequired() 195 | .HasColumnType("nvarchar(450)"); 196 | 197 | b.HasKey("Id"); 198 | 199 | b.HasIndex("RoleId"); 200 | 201 | b.ToTable("AspNetRoleClaims", (string)null); 202 | }); 203 | 204 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => 205 | { 206 | b.Property("Id") 207 | .HasColumnType("nvarchar(450)"); 208 | 209 | b.Property("AccessFailedCount") 210 | .HasColumnType("int"); 211 | 212 | b.Property("ConcurrencyStamp") 213 | .IsConcurrencyToken() 214 | .HasColumnType("nvarchar(max)"); 215 | 216 | b.Property("Email") 217 | .HasMaxLength(256) 218 | .HasColumnType("nvarchar(256)"); 219 | 220 | b.Property("EmailConfirmed") 221 | .HasColumnType("bit"); 222 | 223 | b.Property("LockoutEnabled") 224 | .HasColumnType("bit"); 225 | 226 | b.Property("LockoutEnd") 227 | .HasColumnType("datetimeoffset"); 228 | 229 | b.Property("NormalizedEmail") 230 | .HasMaxLength(256) 231 | .HasColumnType("nvarchar(256)"); 232 | 233 | b.Property("NormalizedUserName") 234 | .HasMaxLength(256) 235 | .HasColumnType("nvarchar(256)"); 236 | 237 | b.Property("PasswordHash") 238 | .HasColumnType("nvarchar(max)"); 239 | 240 | b.Property("PhoneNumber") 241 | .HasColumnType("nvarchar(max)"); 242 | 243 | b.Property("PhoneNumberConfirmed") 244 | .HasColumnType("bit"); 245 | 246 | b.Property("SecurityStamp") 247 | .HasColumnType("nvarchar(max)"); 248 | 249 | b.Property("TwoFactorEnabled") 250 | .HasColumnType("bit"); 251 | 252 | b.Property("UserName") 253 | .HasMaxLength(256) 254 | .HasColumnType("nvarchar(256)"); 255 | 256 | b.HasKey("Id"); 257 | 258 | b.HasIndex("NormalizedEmail") 259 | .HasDatabaseName("EmailIndex"); 260 | 261 | b.HasIndex("NormalizedUserName") 262 | .IsUnique() 263 | .HasDatabaseName("UserNameIndex") 264 | .HasFilter("[NormalizedUserName] IS NOT NULL"); 265 | 266 | b.ToTable("AspNetUsers", (string)null); 267 | }); 268 | 269 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 270 | { 271 | b.Property("Id") 272 | .ValueGeneratedOnAdd() 273 | .HasColumnType("int"); 274 | 275 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 276 | 277 | b.Property("ClaimType") 278 | .HasColumnType("nvarchar(max)"); 279 | 280 | b.Property("ClaimValue") 281 | .HasColumnType("nvarchar(max)"); 282 | 283 | b.Property("UserId") 284 | .IsRequired() 285 | .HasColumnType("nvarchar(450)"); 286 | 287 | b.HasKey("Id"); 288 | 289 | b.HasIndex("UserId"); 290 | 291 | b.ToTable("AspNetUserClaims", (string)null); 292 | }); 293 | 294 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin
Sorry, there's nothing at this address.