├── .gitignore ├── BlazorDemo.sln ├── Client ├── App.razor ├── BlazorDemo.Client.csproj ├── Pages │ ├── Counter.razor │ ├── Index.razor │ ├── Index.razor.css │ ├── Todo │ │ ├── Index.razor │ │ ├── TodoItems.razor │ │ ├── TodoItems.razor.cs │ │ ├── TodoItems.razor.css │ │ ├── TodoLists.razor │ │ ├── TodoLists.razor.cs │ │ ├── TodoState.razor │ │ └── TodoState.razor.cs │ ├── Weather.razor │ └── Weather.razor.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Services │ ├── BlazorDemoApiClients.g.cs │ └── SessionStorageService.cs ├── Shared │ ├── AppState.razor │ ├── CustomValidation.cs │ ├── JsInteropConstants.cs │ ├── JsonBlock.razor │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ ├── NavMenu.razor.css │ └── SurveyPrompt.razor ├── _Imports.razor └── wwwroot │ ├── css │ ├── app.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 │ ├── favicon.ico │ ├── icon-192.png │ ├── images │ ├── banner1.svg │ ├── banner2.svg │ └── banner3.svg │ ├── index.html │ └── scripts │ └── BlazorDemo.js ├── README.md ├── Server ├── BlazorDemo.Server.csproj ├── Controllers │ ├── TodoItemsController.cs │ ├── TodoListsController.cs │ ├── ValuesController.cs │ └── WeatherController.cs ├── Data │ └── ApplicationDbContext.cs ├── Migrations │ ├── 20211013104015_InitialCreate.Designer.cs │ ├── 20211013104015_InitialCreate.cs │ └── ApplicationDbContextModelSnapshot.cs ├── Pages │ ├── Error.cshtml │ └── Error.cshtml.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── Validators │ └── TodoListValidator.cs ├── appsettings.Development.json ├── appsettings.json ├── config.nswag └── wwwroot │ └── api │ └── v1 │ └── specification.json └── Shared ├── BlazorDemo.Shared.csproj ├── TodoItem.cs ├── TodoItemPriority.cs ├── TodoItemState.cs ├── TodoList.cs ├── TodoListValidator.cs └── WeatherForecast.cs /.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/master/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 | # Tye 66 | .tye/ 67 | 68 | # ASP.NET Scaffolding 69 | ScaffoldingReadMe.txt 70 | 71 | # StyleCop 72 | StyleCopReport.xml 73 | 74 | # Files built by Visual Studio 75 | *_i.c 76 | *_p.c 77 | *_h.h 78 | *.ilk 79 | *.meta 80 | *.obj 81 | *.iobj 82 | *.pch 83 | *.pdb 84 | *.ipdb 85 | *.pgc 86 | *.pgd 87 | *.rsp 88 | *.sbr 89 | *.tlb 90 | *.tli 91 | *.tlh 92 | *.tmp 93 | *.tmp_proj 94 | *_wpftmp.csproj 95 | *.log 96 | *.vspscc 97 | *.vssscc 98 | .builds 99 | *.pidb 100 | *.svclog 101 | *.scc 102 | 103 | # Chutzpah Test files 104 | _Chutzpah* 105 | 106 | # Visual C++ cache files 107 | ipch/ 108 | *.aps 109 | *.ncb 110 | *.opendb 111 | *.opensdf 112 | *.sdf 113 | *.cachefile 114 | *.VC.db 115 | *.VC.VC.opendb 116 | 117 | # Visual Studio profiler 118 | *.psess 119 | *.vsp 120 | *.vspx 121 | *.sap 122 | 123 | # Visual Studio Trace Files 124 | *.e2e 125 | 126 | # TFS 2012 Local Workspace 127 | $tf/ 128 | 129 | # Guidance Automation Toolkit 130 | *.gpState 131 | 132 | # ReSharper is a .NET coding add-in 133 | _ReSharper*/ 134 | *.[Rr]e[Ss]harper 135 | *.DotSettings.user 136 | 137 | # TeamCity is a build add-in 138 | _TeamCity* 139 | 140 | # DotCover is a Code Coverage Tool 141 | *.dotCover 142 | 143 | # AxoCover is a Code Coverage Tool 144 | .axoCover/* 145 | !.axoCover/settings.json 146 | 147 | # Coverlet is a free, cross platform Code Coverage Tool 148 | coverage*.json 149 | coverage*.xml 150 | coverage*.info 151 | 152 | # Visual Studio code coverage results 153 | *.coverage 154 | *.coveragexml 155 | 156 | # NCrunch 157 | _NCrunch_* 158 | .*crunch*.local.xml 159 | nCrunchTemp_* 160 | 161 | # MightyMoose 162 | *.mm.* 163 | AutoTest.Net/ 164 | 165 | # Web workbench (sass) 166 | .sass-cache/ 167 | 168 | # Installshield output folder 169 | [Ee]xpress/ 170 | 171 | # DocProject is a documentation generator add-in 172 | DocProject/buildhelp/ 173 | DocProject/Help/*.HxT 174 | DocProject/Help/*.HxC 175 | DocProject/Help/*.hhc 176 | DocProject/Help/*.hhk 177 | DocProject/Help/*.hhp 178 | DocProject/Help/Html2 179 | DocProject/Help/html 180 | 181 | # Click-Once directory 182 | publish/ 183 | 184 | # Publish Web Output 185 | *.[Pp]ublish.xml 186 | *.azurePubxml 187 | # Note: Comment the next line if you want to checkin your web deploy settings, 188 | # but database connection strings (with potential passwords) will be unencrypted 189 | *.pubxml 190 | *.publishproj 191 | 192 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 193 | # checkin your Azure Web App publish settings, but sensitive information contained 194 | # in these scripts will be unencrypted 195 | PublishScripts/ 196 | 197 | # NuGet Packages 198 | *.nupkg 199 | # NuGet Symbol Packages 200 | *.snupkg 201 | # The packages folder can be ignored because of Package Restore 202 | **/[Pp]ackages/* 203 | # except build/, which is used as an MSBuild target. 204 | !**/[Pp]ackages/build/ 205 | # Uncomment if necessary however generally it will be regenerated when needed 206 | #!**/[Pp]ackages/repositories.config 207 | # NuGet v3's project.json files produces more ignorable files 208 | *.nuget.props 209 | *.nuget.targets 210 | 211 | # Microsoft Azure Build Output 212 | csx/ 213 | *.build.csdef 214 | 215 | # Microsoft Azure Emulator 216 | ecf/ 217 | rcf/ 218 | 219 | # Windows Store app package directories and files 220 | AppPackages/ 221 | BundleArtifacts/ 222 | Package.StoreAssociation.xml 223 | _pkginfo.txt 224 | *.appx 225 | *.appxbundle 226 | *.appxupload 227 | 228 | # Visual Studio cache files 229 | # files ending in .cache can be ignored 230 | *.[Cc]ache 231 | # but keep track of directories ending in .cache 232 | !?*.[Cc]ache/ 233 | 234 | # Others 235 | ClientBin/ 236 | ~$* 237 | *~ 238 | *.dbmdl 239 | *.dbproj.schemaview 240 | *.jfm 241 | *.pfx 242 | *.publishsettings 243 | orleans.codegen.cs 244 | 245 | # Including strong name files can present a security risk 246 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 247 | #*.snk 248 | 249 | # Since there are multiple workflows, uncomment next line to ignore bower_components 250 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 251 | #bower_components/ 252 | 253 | # RIA/Silverlight projects 254 | Generated_Code/ 255 | 256 | # Backup & report files from converting an old project file 257 | # to a newer Visual Studio version. Backup files are not needed, 258 | # because we have git ;-) 259 | _UpgradeReport_Files/ 260 | Backup*/ 261 | UpgradeLog*.XML 262 | UpgradeLog*.htm 263 | ServiceFabricBackup/ 264 | *.rptproj.bak 265 | 266 | # SQL Server files 267 | *.mdf 268 | *.ldf 269 | *.ndf 270 | 271 | # Business Intelligence projects 272 | *.rdl.data 273 | *.bim.layout 274 | *.bim_*.settings 275 | *.rptproj.rsuser 276 | *- [Bb]ackup.rdl 277 | *- [Bb]ackup ([0-9]).rdl 278 | *- [Bb]ackup ([0-9][0-9]).rdl 279 | 280 | # Microsoft Fakes 281 | FakesAssemblies/ 282 | 283 | # GhostDoc plugin setting file 284 | *.GhostDoc.xml 285 | 286 | # Node.js Tools for Visual Studio 287 | .ntvs_analysis.dat 288 | node_modules/ 289 | 290 | # Visual Studio 6 build log 291 | *.plg 292 | 293 | # Visual Studio 6 workspace options file 294 | *.opt 295 | 296 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 297 | *.vbw 298 | 299 | # Visual Studio LightSwitch build output 300 | **/*.HTMLClient/GeneratedArtifacts 301 | **/*.DesktopClient/GeneratedArtifacts 302 | **/*.DesktopClient/ModelManifest.xml 303 | **/*.Server/GeneratedArtifacts 304 | **/*.Server/ModelManifest.xml 305 | _Pvt_Extensions 306 | 307 | # Paket dependency manager 308 | .paket/paket.exe 309 | paket-files/ 310 | 311 | # FAKE - F# Make 312 | .fake/ 313 | 314 | # CodeRush personal settings 315 | .cr/personal 316 | 317 | # Python Tools for Visual Studio (PTVS) 318 | __pycache__/ 319 | *.pyc 320 | 321 | # Cake - Uncomment if you are using it 322 | # tools/** 323 | # !tools/packages.config 324 | 325 | # Tabs Studio 326 | *.tss 327 | 328 | # Telerik's JustMock configuration file 329 | *.jmconfig 330 | 331 | # BizTalk build output 332 | *.btp.cs 333 | *.btm.cs 334 | *.odx.cs 335 | *.xsd.cs 336 | 337 | # OpenCover UI analysis results 338 | OpenCover/ 339 | 340 | # Azure Stream Analytics local run output 341 | ASALocalRun/ 342 | 343 | # MSBuild Binary and Structured Log 344 | *.binlog 345 | 346 | # NVidia Nsight GPU debugger configuration file 347 | *.nvuser 348 | 349 | # MFractors (Xamarin productivity tool) working folder 350 | .mfractor/ 351 | 352 | # Local History for Visual Studio 353 | .localhistory/ 354 | 355 | # BeatPulse healthcheck temp database 356 | healthchecksdb 357 | 358 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 359 | MigrationBackup/ 360 | 361 | # Ionide (cross platform F# VS Code tools) working folder 362 | .ionide/ 363 | 364 | # Fody - auto-generated XML schema 365 | FodyWeavers.xsd 366 | 367 | ## 368 | ## Visual studio for Mac 369 | ## 370 | 371 | 372 | # globs 373 | Makefile.in 374 | *.userprefs 375 | *.usertasks 376 | config.make 377 | config.status 378 | aclocal.m4 379 | install-sh 380 | autom4te.cache/ 381 | *.tar.gz 382 | tarballs/ 383 | test-results/ 384 | 385 | # Mac bundle stuff 386 | *.dmg 387 | *.app 388 | 389 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 390 | # General 391 | .DS_Store 392 | .AppleDouble 393 | .LSOverride 394 | 395 | # Icon must end with two \r 396 | Icon 397 | 398 | 399 | # Thumbnails 400 | ._* 401 | 402 | # Files that might appear in the root of a volume 403 | .DocumentRevisions-V100 404 | .fseventsd 405 | .Spotlight-V100 406 | .TemporaryItems 407 | .Trashes 408 | .VolumeIcon.icns 409 | .com.apple.timemachine.donotpresent 410 | 411 | # Directories potentially created on remote AFP share 412 | .AppleDB 413 | .AppleDesktop 414 | Network Trash Folder 415 | Temporary Items 416 | .apdisk 417 | 418 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 419 | # Windows thumbnail cache files 420 | Thumbs.db 421 | ehthumbs.db 422 | ehthumbs_vista.db 423 | 424 | # Dump file 425 | *.stackdump 426 | 427 | # Folder config file 428 | [Dd]esktop.ini 429 | 430 | # Recycle Bin used on file shares 431 | $RECYCLE.BIN/ 432 | 433 | # Windows Installer files 434 | *.cab 435 | *.msi 436 | *.msix 437 | *.msm 438 | *.msp 439 | 440 | # Windows shortcuts 441 | *.lnk 442 | 443 | # JetBrains Rider 444 | .idea/ 445 | *.sln.iml 446 | 447 | ## 448 | ## Visual Studio Code 449 | ## 450 | .vscode/* 451 | !.vscode/settings.json 452 | !.vscode/tasks.json 453 | !.vscode/launch.json 454 | !.vscode/extensions.json 455 | -------------------------------------------------------------------------------- /BlazorDemo.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 17 3 | VisualStudioVersion = 17.0.31717.71 4 | MinimumVisualStudioVersion = 16.0.0.0 5 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorDemo.Server", "Server\BlazorDemo.Server.csproj", "{7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}" 6 | EndProject 7 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorDemo.Client", "Client\BlazorDemo.Client.csproj", "{C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}" 8 | EndProject 9 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorDemo.Shared", "Shared\BlazorDemo.Shared.csproj", "{221CC841-7E2A-4B26-8A38-F614E592B387}" 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Any CPU = Debug|Any CPU 14 | Debug|x64 = Debug|x64 15 | Debug|x86 = Debug|x86 16 | Release|Any CPU = Release|Any CPU 17 | Release|x64 = Release|x64 18 | Release|x86 = Release|x86 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Debug|x64.ActiveCfg = Debug|Any CPU 24 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Debug|x64.Build.0 = Debug|Any CPU 25 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Debug|x86.ActiveCfg = Debug|Any CPU 26 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Debug|x86.Build.0 = Debug|Any CPU 27 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Release|x64.ActiveCfg = Release|Any CPU 30 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Release|x64.Build.0 = Release|Any CPU 31 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Release|x86.ActiveCfg = Release|Any CPU 32 | {7E6D6C5E-D0A5-4F5D-93AE-393665BF4752}.Release|x86.Build.0 = Release|Any CPU 33 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Debug|Any CPU.Build.0 = Debug|Any CPU 35 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Debug|x64.ActiveCfg = Debug|Any CPU 36 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Debug|x64.Build.0 = Debug|Any CPU 37 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Debug|x86.ActiveCfg = Debug|Any CPU 38 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Debug|x86.Build.0 = Debug|Any CPU 39 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Release|Any CPU.ActiveCfg = Release|Any CPU 40 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Release|Any CPU.Build.0 = Release|Any CPU 41 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Release|x64.ActiveCfg = Release|Any CPU 42 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Release|x64.Build.0 = Release|Any CPU 43 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Release|x86.ActiveCfg = Release|Any CPU 44 | {C8BCA92B-BA69-4688-AC9F-3D92A40BA1AA}.Release|x86.Build.0 = Release|Any CPU 45 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 46 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Debug|Any CPU.Build.0 = Debug|Any CPU 47 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Debug|x64.ActiveCfg = Debug|Any CPU 48 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Debug|x64.Build.0 = Debug|Any CPU 49 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Debug|x86.ActiveCfg = Debug|Any CPU 50 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Debug|x86.Build.0 = Debug|Any CPU 51 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Release|Any CPU.ActiveCfg = Release|Any CPU 52 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Release|Any CPU.Build.0 = Release|Any CPU 53 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Release|x64.ActiveCfg = Release|Any CPU 54 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Release|x64.Build.0 = Release|Any CPU 55 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Release|x86.ActiveCfg = Release|Any CPU 56 | {221CC841-7E2A-4B26-8A38-F614E592B387}.Release|x86.Build.0 = Release|Any CPU 57 | EndGlobalSection 58 | GlobalSection(SolutionProperties) = preSolution 59 | HideSolutionNode = FALSE 60 | EndGlobalSection 61 | GlobalSection(ExtensibilityGlobals) = postSolution 62 | SolutionGuid = {EB743240-9229-449A-8897-FB19B408F297} 63 | EndGlobalSection 64 | EndGlobal 65 | -------------------------------------------------------------------------------- /Client/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 |
-------------------------------------------------------------------------------- /Client/BlazorDemo.Client.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Client/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 | Counter 4 | 5 |

Counter

6 | 7 |

Current count: @AppState.CurrentCount

8 | 9 | 10 | 11 | @code { 12 | [CascadingParameter] public AppState AppState { get; set; } = null!; 13 | 14 | private void IncrementCount() 15 | { 16 | AppState.CurrentCount++; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Client/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 |
6 | 7 | 57 | 58 |
59 |
60 |

Application uses

61 | 69 |
70 | 78 | 86 |
87 |

Packages

88 | 92 |
93 |
94 | 95 |

For everything else visit: Awesome Blazor Awesome

96 | 97 | 98 |
-------------------------------------------------------------------------------- /Client/Pages/Index.razor.css: -------------------------------------------------------------------------------- 1 | /* Carousel */ 2 | .carousel-caption p { 3 | font-size: 20px; 4 | line-height: 1.4; 5 | } 6 | 7 | h2 { 8 | margin-top: 20px; 9 | } 10 | 11 | /* Make .svg files in the carousel display properly in older browsers */ 12 | .carousel-inner .item img[src$=".svg"] { 13 | width: 100%; 14 | } 15 | 16 | /* Hide/rearrange for smaller screens */ 17 | @media screen and (max-width: 767px) { 18 | /* Hide captions */ 19 | .carousel-caption { 20 | display: none; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Client/Pages/Todo/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/todo" 2 | 3 | Todo 4 | 5 |

Todo

6 | 7 |

This component demonstrates ...

8 | 9 | 10 |
11 |
12 | 13 |
14 |
15 | 16 |
17 |
18 |
-------------------------------------------------------------------------------- /Client/Pages/Todo/TodoItems.razor: -------------------------------------------------------------------------------- 1 | @if (State.Initialised) 2 | { 3 |
4 |

@State.SelectedList.Title

5 | 8 |
9 | 10 | 37 | 38 | 74 | } -------------------------------------------------------------------------------- /Client/Pages/Todo/TodoItems.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorDemo.Client.Shared; 2 | using BlazorDemo.Shared; 3 | using Microsoft.AspNetCore.Components; 4 | using Microsoft.JSInterop; 5 | 6 | namespace BlazorDemo.Client.Pages.Todo 7 | { 8 | public partial class TodoItems 9 | { 10 | [CascadingParameter] public TodoState State { get; set; } 11 | 12 | public TodoItem SelectedItem { get; set; } 13 | 14 | private ElementReference _titleInput; 15 | 16 | private ElementReference _listOptionsModal; 17 | 18 | public bool IsSelectedItem(TodoItem item) 19 | { 20 | return SelectedItem == item; 21 | 22 | } 23 | 24 | private async Task AddItem() 25 | { 26 | var newItem = new TodoItem { ListId = State.SelectedList.Id }; 27 | 28 | State.SelectedList.Items.Add(newItem); 29 | 30 | await EditItem(newItem); 31 | } 32 | 33 | private async Task ToggleDone(TodoItem item, ChangeEventArgs args) 34 | { 35 | if (args != null && args.Value is bool value) 36 | { 37 | item.Done = value; 38 | 39 | await State.TodoItemsClient.PutTodoItemAsync(item.Id, item); 40 | } 41 | } 42 | 43 | private async Task EditItem(TodoItem item) 44 | { 45 | SelectedItem = item; 46 | 47 | await Task.Delay(50); 48 | 49 | if (_titleInput.Context != null) 50 | { 51 | await _titleInput.FocusAsync(); 52 | } 53 | } 54 | 55 | private async Task SaveItem() 56 | { 57 | if (SelectedItem.Id == 0) 58 | { 59 | if (string.IsNullOrWhiteSpace(SelectedItem.Title)) 60 | { 61 | State.SelectedList.Items.Remove(SelectedItem); 62 | } 63 | else 64 | { 65 | var item = await State.TodoItemsClient.PostTodoItemAsync(SelectedItem); 66 | 67 | SelectedItem.Id = item.Id; 68 | } 69 | } 70 | else 71 | { 72 | if (string.IsNullOrWhiteSpace(SelectedItem.Title)) 73 | { 74 | await State.TodoItemsClient.DeleteTodoItemAsync(SelectedItem.Id); 75 | State.SelectedList.Items.Remove(SelectedItem); 76 | } 77 | else 78 | { 79 | await State.TodoItemsClient.PutTodoItemAsync(SelectedItem.Id, SelectedItem); 80 | } 81 | } 82 | } 83 | 84 | private async Task SaveList() 85 | { 86 | await State.TodoListsClient.PutTodoListAsync(State.SelectedList.Id, State.SelectedList); 87 | 88 | State.JS.InvokeVoid(JsInteropConstants.HideModal, _listOptionsModal); 89 | 90 | State.SyncList(); 91 | } 92 | 93 | private async Task DeleteList() 94 | { 95 | await State.TodoListsClient.DeleteTodoListAsync(State.SelectedList.Id); 96 | 97 | State.JS.InvokeVoid(JsInteropConstants.HideModal, _listOptionsModal); 98 | 99 | await State.DeleteList(); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Client/Pages/Todo/TodoItems.razor.css: -------------------------------------------------------------------------------- 1 | #todo-items .item-input-control { 2 | border: 0; 3 | box-shadow: none; 4 | background-color: transparent; 5 | } 6 | 7 | #todo-items .done-todo { 8 | text-decoration: line-through; 9 | } 10 | 11 | #todo-items .todo-item-title { 12 | padding-top: 8px; 13 | } 14 | 15 | #todo-items .list-group-item { 16 | padding-top: 8px; 17 | padding-bottom: 8px; 18 | } 19 | 20 | #todo-items .list-group-item .btn-xs { 21 | padding: 0; 22 | } 23 | 24 | #todo-items .todo-item-checkbox { 25 | padding-top: 8px; 26 | } 27 | 28 | #todo-items .todo-item-commands { 29 | padding-top: 4px; 30 | } -------------------------------------------------------------------------------- /Client/Pages/Todo/TodoLists.razor: -------------------------------------------------------------------------------- 1 | @if (State.Initialised) 2 | { 3 |
4 |

Lists

5 | 8 |
9 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Client/Pages/Todo/TodoLists.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorDemo.Client.Shared; 2 | using BlazorDemo.Shared; 3 | using Microsoft.AspNetCore.Components; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.JSInterop; 6 | using Newtonsoft.Json; 7 | 8 | namespace BlazorDemo.Client.Pages.Todo 9 | { 10 | public partial class TodoLists 11 | { 12 | [CascadingParameter] public TodoState State { get; set; } 13 | 14 | private ElementReference _titleInput; 15 | 16 | private ElementReference _newListModal; 17 | 18 | private TodoList _newTodoList = new TodoList(); 19 | 20 | private CustomValidation _customValidation; 21 | 22 | private async Task NewList() 23 | { 24 | _newTodoList = new TodoList(); 25 | 26 | await Task.Delay(500); 27 | 28 | if (_titleInput.Context != null) 29 | { 30 | await _titleInput.FocusAsync(); 31 | } 32 | } 33 | 34 | private async Task CreateNewList() 35 | { 36 | _customValidation.ClearErrors(); 37 | 38 | try 39 | { 40 | var list = await State.TodoListsClient.PostTodoListAsync(_newTodoList); 41 | 42 | State.TodoLists.Add(list); 43 | 44 | await SelectList(list); 45 | 46 | State.JS.InvokeVoid(JsInteropConstants.HideModal, _newListModal); 47 | } 48 | catch (ApiException ex) 49 | { 50 | var problemDetails = JsonConvert.DeserializeObject(ex.Response); 51 | 52 | if (problemDetails != null) 53 | { 54 | _customValidation.DisplayErrors(problemDetails.Errors); 55 | } 56 | } 57 | 58 | } 59 | 60 | private bool IsSelected(TodoList list) 61 | { 62 | return State.SelectedList.Id == list.Id; 63 | } 64 | 65 | private async Task SelectList(TodoList list) 66 | { 67 | if (IsSelected(list)) return; 68 | 69 | State.SelectedList = await State.TodoListsClient.GetTodoListAsync(list.Id); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Client/Pages/Todo/TodoState.razor: -------------------------------------------------------------------------------- 1 |  2 | @ChildContent 3 | -------------------------------------------------------------------------------- /Client/Pages/Todo/TodoState.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorDemo.Shared; 2 | using Microsoft.AspNetCore.Components; 3 | using Microsoft.JSInterop; 4 | 5 | namespace BlazorDemo.Client.Pages.Todo 6 | { 7 | public partial class TodoState 8 | { 9 | [Parameter] public RenderFragment ChildContent { get; set; } 10 | 11 | [Inject] public ITodoListsClient TodoListsClient { get; set; } 12 | 13 | [Inject] public ITodoItemsClient TodoItemsClient { get; set; } 14 | 15 | [Inject] public IJSInProcessRuntime JS { get; set; } 16 | 17 | public ICollection TodoLists { get; set; } 18 | 19 | private TodoList _selectedList; 20 | 21 | public TodoList SelectedList 22 | { 23 | get { return _selectedList; } 24 | set 25 | { 26 | _selectedList = value; 27 | StateHasChanged(); 28 | } 29 | } 30 | 31 | public void SyncList() 32 | { 33 | var list = TodoLists.First(l => l.Id == SelectedList.Id); 34 | 35 | list.Title = SelectedList.Title; 36 | 37 | StateHasChanged(); 38 | } 39 | 40 | public async Task DeleteList() 41 | { 42 | var list = TodoLists.First(l => l.Id == SelectedList.Id); 43 | 44 | TodoLists.Remove(list); 45 | 46 | SelectedList = await TodoListsClient.GetTodoListAsync(TodoLists.First().Id); 47 | 48 | StateHasChanged(); 49 | } 50 | 51 | public bool Initialised { get; set; } 52 | 53 | protected override async Task OnInitializedAsync() 54 | { 55 | TodoLists = await TodoListsClient.GetTodoListsAsync(); 56 | SelectedList = await TodoListsClient.GetTodoListAsync(TodoLists.First().Id); 57 | Initialised = true; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Client/Pages/Weather.razor: -------------------------------------------------------------------------------- 1 | @page "/weather" 2 | 3 | Weather 4 | 5 |

Weather

6 | 7 |

This component demonstrates fetching data from the server.

8 | 9 | @if (forecasts == null) 10 | { 11 |

Loading...

12 | } 13 | else 14 | { 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | @foreach (var forecast in forecasts) 26 | { 27 | 28 | 29 | 30 | 31 | 32 | 33 | } 34 | 35 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
36 | } -------------------------------------------------------------------------------- /Client/Pages/Weather.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorDemo.Shared; 2 | using Microsoft.AspNetCore.Components; 3 | 4 | namespace BlazorDemo.Client.Pages 5 | { 6 | public partial class Weather : ComponentBase 7 | { 8 | [Inject] private IWeatherClient Client { get; set; } 9 | 10 | private ICollection forecasts; 11 | 12 | protected override async Task OnInitializedAsync() 13 | { 14 | forecasts = await Client.GetAsync(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Client/Program.cs: -------------------------------------------------------------------------------- 1 | using BlazorDemo.Client; 2 | using BlazorDemo.Client.Services; 3 | using BlazorDemo.Shared; 4 | using FluentValidation; 5 | using Microsoft.AspNetCore.Components.Web; 6 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 7 | using Microsoft.JSInterop; 8 | using Toolbelt.Blazor.Extensions.DependencyInjection; 9 | 10 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 11 | builder.RootComponents.Add("#app"); 12 | builder.RootComponents.Add("head::after"); 13 | 14 | builder.Services.AddHttpClientInterceptor(); 15 | 16 | builder.Services.AddScoped(sp => 17 | new HttpClient 18 | { 19 | BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) 20 | }.EnableIntercept(sp)); 21 | 22 | builder.Services.AddSingleton(services => 23 | (IJSInProcessRuntime)services.GetRequiredService()); 24 | 25 | builder.Services.AddLoadingBar(); 26 | 27 | builder.Services.AddValidatorsFromAssemblyContaining(); 28 | 29 | builder.Services.AddScoped(); 30 | 31 | builder.Services.Scan(scan => scan 32 | .FromAssemblyOf() 33 | .AddClasses().AsImplementedInterfaces() 34 | .WithScopedLifetime()); 35 | 36 | builder.UseLoadingBar(); 37 | 38 | await builder.Build().RunAsync(); 39 | -------------------------------------------------------------------------------- /Client/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:32755", 7 | "sslPort": 44318 8 | } 9 | }, 10 | "profiles": { 11 | "BlazorDemo": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "hotReloadProfile": "blazorwasm", 16 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 17 | "applicationUrl": "https://localhost:7270;http://localhost:5194", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "IIS Express": { 23 | "commandName": "IISExpress", 24 | "launchBrowser": true, 25 | "hotReloadProfile": "blazorwasm", 26 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 27 | "environmentVariables": { 28 | "ASPNETCORE_ENVIRONMENT": "Development" 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Client/Services/SessionStorageService.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json; 2 | using Microsoft.JSInterop; 3 | 4 | namespace BlazorDemo.Client.Services 5 | { 6 | public class SessionStorageService 7 | { 8 | private readonly IJSRuntime _js; 9 | private readonly IJSInProcessRuntime _jsInProcess; 10 | 11 | public SessionStorageService(IJSRuntime js) 12 | { 13 | _js = js; 14 | _jsInProcess = (IJSInProcessRuntime)_js; 15 | } 16 | 17 | public async Task GetItemAsync(string key) 18 | { 19 | var json = await _js.InvokeAsync( 20 | "blazorDemo.getSessionStorage", 21 | key); 22 | 23 | return string.IsNullOrEmpty(json) 24 | ? default 25 | : JsonSerializer.Deserialize(json); 26 | } 27 | 28 | public async Task SetItemAsync(string key, T item) 29 | { 30 | await _js.InvokeVoidAsync( 31 | "blazorDemo.setSessionStorage", 32 | key, 33 | JsonSerializer.Serialize(item)); 34 | } 35 | 36 | public void SetItem(string key, T item) 37 | { 38 | _jsInProcess.InvokeVoid( 39 | "blazorDemo.setSessionStorage", 40 | key, 41 | JsonSerializer.Serialize(item)); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Client/Shared/AppState.razor: -------------------------------------------------------------------------------- 1 | @inject IJSInProcessRuntime JS 2 | 3 | 4 | @ChildContent 5 | 6 | 7 | @code { 8 | [Parameter] public RenderFragment ChildContent { get; set; } 9 | 10 | private int _currentCount; 11 | 12 | public int CurrentCount 13 | { 14 | get 15 | { 16 | return _currentCount; 17 | } 18 | set 19 | { 20 | _currentCount = value; 21 | 22 | JS.InvokeVoid(JsInteropConstants.SetSessionStorage, nameof(CurrentCount), value); 23 | 24 | StateHasChanged(); 25 | } 26 | } 27 | 28 | protected override void OnInitialized() 29 | { 30 | var value = JS.Invoke(JsInteropConstants.GetSessionStorage, nameof(CurrentCount)); 31 | 32 | int.TryParse(value, out _currentCount); 33 | } 34 | } -------------------------------------------------------------------------------- /Client/Shared/CustomValidation.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.Components.Forms; 3 | 4 | namespace BlazorDemo.Client.Shared 5 | { 6 | public class CustomValidation : ComponentBase 7 | { 8 | private ValidationMessageStore _messageStore; 9 | 10 | [CascadingParameter] 11 | private EditContext CurrentEditContext { get; set; } 12 | 13 | protected override void OnInitialized() 14 | { 15 | if (CurrentEditContext == null) 16 | { 17 | throw new InvalidOperationException( 18 | $"{nameof(CustomValidation)} requires a cascading " + 19 | $"parameter of type {nameof(EditContext)}. " + 20 | $"For example, you can use {nameof(CustomValidation)} " + 21 | $"inside an {nameof(EditForm)}."); 22 | } 23 | 24 | // Create a validation message store for the given form 25 | _messageStore = new(CurrentEditContext); 26 | 27 | // Clear validation errors when validation requested. 28 | CurrentEditContext.OnValidationRequested += (s, e) => 29 | _messageStore.Clear(); 30 | 31 | // Clear validation error when field changes. 32 | CurrentEditContext.OnFieldChanged += (s, e) => 33 | _messageStore.Clear(e.FieldIdentifier); 34 | } 35 | 36 | public void DisplayErrors(IDictionary errors) 37 | { 38 | foreach (var err in errors) 39 | { 40 | _messageStore.Add(CurrentEditContext.Field(err.Key), err.Value); 41 | } 42 | 43 | CurrentEditContext.NotifyValidationStateChanged(); 44 | } 45 | 46 | public void ClearErrors() 47 | { 48 | _messageStore.Clear(); 49 | 50 | CurrentEditContext.NotifyValidationStateChanged(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Client/Shared/JsInteropConstants.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorDemo.Client.Shared 2 | { 3 | public static class JsInteropConstants 4 | { 5 | private const string FuncPrefix = "blazorDemo"; 6 | 7 | public const string GetSessionStorage = $"{FuncPrefix}.getSessionStorage"; 8 | 9 | public const string SetSessionStorage = $"{FuncPrefix}.setSessionStorage"; 10 | 11 | public const string HideModal = $"{FuncPrefix}.hideModal"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Client/Shared/JsonBlock.razor: -------------------------------------------------------------------------------- 1 | @using System.Text.Json 2 | 3 |
4 | 5 |
@(JsonSerializer.Serialize(Data, new JsonSerializerOptions { WriteIndented = true }))
6 |
7 |
8 | 9 | @code { 10 | [Parameter] 11 | public object Data { get; set; } = null!; 12 | } -------------------------------------------------------------------------------- /Client/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | Current count: @AppState.CurrentCount 11 | About 12 |
13 | 14 |
15 | @Body 16 |
17 |
18 |
19 | 20 | @code { 21 | [CascadingParameter] AppState AppState { get; set; } 22 | } -------------------------------------------------------------------------------- /Client/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row:not(.auth) { 41 | display: none; 42 | } 43 | 44 | .top-row.auth { 45 | justify-content: space-between; 46 | } 47 | 48 | .top-row ::deep a, .top-row ::deep .btn-link { 49 | margin-left: 0; 50 | } 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .page { 55 | flex-direction: row; 56 | } 57 | 58 | .sidebar { 59 | width: 250px; 60 | height: 100vh; 61 | position: sticky; 62 | top: 0; 63 | } 64 | 65 | .top-row { 66 | position: sticky; 67 | top: 0; 68 | z-index: 1; 69 | } 70 | 71 | .top-row.auth ::deep a:first-child { 72 | flex: 1; 73 | text-align: right; 74 | width: 0; 75 | } 76 | 77 | .top-row, article { 78 | padding-left: 2rem !important; 79 | padding-right: 1.5rem !important; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Client/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 |
11 | 33 |
34 | 35 | @code { 36 | private bool collapseNavMenu = true; 37 | 38 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 39 | 40 | private void ToggleNavMenu() 41 | { 42 | collapseNavMenu = !collapseNavMenu; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Client/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Client/Shared/SurveyPrompt.razor: -------------------------------------------------------------------------------- 1 | 
2 | 3 | @Title 4 | 5 | 6 | Please take our 7 | brief survey 8 | 9 | and tell us what you think. 10 |
11 | 12 | @code { 13 | // Demonstrates how a parent component can supply parameters 14 | [Parameter] 15 | public string Title { get; set; } 16 | } 17 | -------------------------------------------------------------------------------- /Client/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using BlazorDemo.Client 10 | @using BlazorDemo.Client.Shared 11 | @using BlazorDemo.Client.Services 12 | @using BlazorDemo.Shared 13 | @using Blazored.FluentValidation 14 | 15 | -------------------------------------------------------------------------------- /Client/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | h1:focus { 8 | outline: none; 9 | } 10 | 11 | a, .btn-link { 12 | color: #0077cc; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .content { 22 | padding-top: 1.1rem; 23 | } 24 | 25 | .valid.modified:not([type=checkbox]) { 26 | outline: 1px solid #26b050; 27 | } 28 | 29 | .invalid { 30 | outline: 1px solid red; 31 | } 32 | 33 | .validation-message { 34 | color: red; 35 | } 36 | 37 | #blazor-error-ui { 38 | background: lightyellow; 39 | bottom: 0; 40 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 41 | display: none; 42 | left: 0; 43 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 44 | position: fixed; 45 | width: 100%; 46 | z-index: 1000; 47 | } 48 | 49 | #blazor-error-ui .dismiss { 50 | cursor: pointer; 51 | position: absolute; 52 | right: 0.75rem; 53 | top: 0.5rem; 54 | } 55 | 56 | .blazor-error-boundary { 57 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 58 | padding: 1rem 1rem 1rem 3.7rem; 59 | color: white; 60 | } 61 | 62 | .blazor-error-boundary::after { 63 | content: "An error has occurred." 64 | } 65 | -------------------------------------------------------------------------------- /Client/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /Client/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Client/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasontaylordev/ModernWebDevWithBlazorWasm/5aecc676d07ec0e2e46d50e28ed4975ed5572625/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasontaylordev/ModernWebDevWithBlazorWasm/5aecc676d07ec0e2e46d50e28ed4975ed5572625/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014 9 | By P.J. Onori 10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net) 11 | 12 | 13 | 14 | 27 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 74 | 76 | 79 | 81 | 84 | 86 | 88 | 91 | 93 | 95 | 98 | 100 | 102 | 104 | 106 | 109 | 112 | 115 | 117 | 121 | 123 | 125 | 127 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 162 | 165 | 167 | 169 | 172 | 174 | 177 | 179 | 181 | 183 | 185 | 189 | 191 | 194 | 196 | 198 | 200 | 202 | 205 | 207 | 209 | 211 | 213 | 215 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 241 | 243 | 245 | 247 | 249 | 251 | 253 | 256 | 259 | 261 | 263 | 265 | 267 | 269 | 272 | 274 | 276 | 280 | 282 | 285 | 287 | 289 | 292 | 295 | 298 | 300 | 302 | 304 | 306 | 309 | 312 | 314 | 316 | 318 | 320 | 322 | 324 | 326 | 330 | 334 | 338 | 340 | 343 | 345 | 347 | 349 | 351 | 353 | 355 | 358 | 360 | 363 | 365 | 367 | 369 | 371 | 373 | 375 | 377 | 379 | 381 | 383 | 386 | 388 | 390 | 392 | 394 | 396 | 399 | 401 | 404 | 406 | 408 | 410 | 412 | 414 | 416 | 419 | 421 | 423 | 425 | 428 | 431 | 435 | 438 | 440 | 442 | 444 | 446 | 448 | 451 | 453 | 455 | 457 | 460 | 462 | 464 | 466 | 468 | 471 | 473 | 477 | 479 | 481 | 483 | 486 | 488 | 490 | 492 | 494 | 496 | 499 | 501 | 504 | 506 | 509 | 512 | 515 | 517 | 520 | 522 | 524 | 526 | 529 | 532 | 534 | 536 | 539 | 542 | 543 | 544 | -------------------------------------------------------------------------------- /Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasontaylordev/ModernWebDevWithBlazorWasm/5aecc676d07ec0e2e46d50e28ed4975ed5572625/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasontaylordev/ModernWebDevWithBlazorWasm/5aecc676d07ec0e2e46d50e28ed4975ed5572625/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Client/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasontaylordev/ModernWebDevWithBlazorWasm/5aecc676d07ec0e2e46d50e28ed4975ed5572625/Client/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Client/wwwroot/icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasontaylordev/ModernWebDevWithBlazorWasm/5aecc676d07ec0e2e46d50e28ed4975ed5572625/Client/wwwroot/icon-192.png -------------------------------------------------------------------------------- /Client/wwwroot/images/banner1.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Client/wwwroot/images/banner2.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Client/wwwroot/images/banner3.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Client/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | BlazorDemo 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Client/wwwroot/scripts/BlazorDemo.js: -------------------------------------------------------------------------------- 1 | var blazorDemo = {}; 2 | 3 | blazorDemo.setSessionStorage = function (key, data) { 4 | sessionStorage.setItem(key, data); 5 | } 6 | 7 | blazorDemo.getSessionStorage = function (key) { 8 | return sessionStorage.getItem(key); 9 | } 10 | 11 | blazorDemo.hideModal = function (element) { 12 | bootstrap.Modal.getInstance(element).hide(); 13 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ModernWebDevWithBlazorWasm 2 | The sample code from my presentation Modern Web Dev with Blazor WebAsembly and ASP.NET Core 6. 3 | -------------------------------------------------------------------------------- /Server/BlazorDemo.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | all 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | OnBuildSuccess 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Server/Controllers/TodoItemsController.cs: -------------------------------------------------------------------------------- 1 | using BlazorDemo.Server.Data; 2 | using BlazorDemo.Shared; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.EntityFrameworkCore; 5 | 6 | namespace BlazorDemo.Server.Controllers; 7 | 8 | [Route("api/[controller]")] 9 | [ApiController] 10 | public class TodoItemsController : ControllerBase 11 | { 12 | private readonly ApplicationDbContext _context; 13 | 14 | public TodoItemsController(ApplicationDbContext context) 15 | { 16 | _context = context; 17 | } 18 | 19 | // GET: api/TodoItems/5 20 | [HttpGet("{id}")] 21 | [ProducesResponseType(typeof(TodoItem), StatusCodes.Status200OK)] 22 | [ProducesResponseType(StatusCodes.Status404NotFound)] 23 | public async Task> GetTodoItem(int id) 24 | { 25 | var todoItem = await _context.TodoItems.FindAsync(id); 26 | 27 | if (todoItem == null) 28 | { 29 | return NotFound(); 30 | } 31 | 32 | return todoItem; 33 | } 34 | 35 | // PUT: api/TodoItems/5 36 | // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 37 | [HttpPut("{id}")] 38 | [ProducesResponseType(StatusCodes.Status204NoContent)] 39 | [ProducesResponseType(StatusCodes.Status400BadRequest)] 40 | [ProducesResponseType(StatusCodes.Status404NotFound)] 41 | public async Task PutTodoItem(int id, TodoItem todoItem) 42 | { 43 | if (id != todoItem.Id) 44 | { 45 | return BadRequest(); 46 | } 47 | 48 | _context.Entry(todoItem).State = EntityState.Modified; 49 | 50 | try 51 | { 52 | await _context.SaveChangesAsync(); 53 | } 54 | catch (DbUpdateConcurrencyException) 55 | { 56 | if (!TodoItemExists(id)) 57 | { 58 | return NotFound(); 59 | } 60 | else 61 | { 62 | throw; 63 | } 64 | } 65 | 66 | return NoContent(); 67 | } 68 | 69 | // POST: api/TodoItems 70 | // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 71 | [HttpPost] 72 | [ProducesResponseType(typeof(TodoItem), StatusCodes.Status201Created)] 73 | public async Task> PostTodoItem(TodoItem todoItem) 74 | { 75 | _context.TodoItems.Add(todoItem); 76 | await _context.SaveChangesAsync(); 77 | 78 | return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem); 79 | } 80 | 81 | // DELETE: api/TodoItems/5 82 | [HttpDelete("{id}")] 83 | [ProducesResponseType(StatusCodes.Status204NoContent)] 84 | [ProducesResponseType(StatusCodes.Status404NotFound)] 85 | public async Task DeleteTodoItem(int id) 86 | { 87 | var todoItem = await _context.TodoItems.FindAsync(id); 88 | if (todoItem == null) 89 | { 90 | return NotFound(); 91 | } 92 | 93 | _context.TodoItems.Remove(todoItem); 94 | await _context.SaveChangesAsync(); 95 | 96 | return NoContent(); 97 | } 98 | 99 | private bool TodoItemExists(int id) 100 | { 101 | return _context.TodoItems.Any(e => e.Id == id); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Server/Controllers/TodoListsController.cs: -------------------------------------------------------------------------------- 1 | using BlazorDemo.Server.Data; 2 | using BlazorDemo.Shared; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.EntityFrameworkCore; 5 | 6 | namespace BlazorDemo.Server.Controllers; 7 | 8 | [Route("api/[controller]")] 9 | [ApiController] 10 | public class TodoListsController : ControllerBase 11 | { 12 | private readonly ApplicationDbContext _context; 13 | 14 | public TodoListsController(ApplicationDbContext context) 15 | { 16 | _context = context; 17 | } 18 | 19 | // GET: api/TodoLists 20 | [HttpGet] 21 | public async Task>> GetTodoLists() 22 | { 23 | return await _context.TodoLists.ToListAsync(); 24 | } 25 | 26 | // GET: api/TodoLists/5 27 | [HttpGet("{id}")] 28 | [ProducesResponseType(typeof(TodoList), StatusCodes.Status200OK)] 29 | [ProducesResponseType(StatusCodes.Status404NotFound)] 30 | public async Task> GetTodoList(int id) 31 | { 32 | var todoList = await _context.TodoLists 33 | .Include(tl => tl.Items) 34 | .FirstOrDefaultAsync(tl => tl.Id == id); 35 | 36 | if (todoList == null) 37 | { 38 | return NotFound(); 39 | } 40 | 41 | return todoList; 42 | } 43 | 44 | // PUT: api/TodoLists/5 45 | // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 46 | [HttpPut("{id}")] 47 | [ProducesResponseType(StatusCodes.Status204NoContent)] 48 | [ProducesResponseType(StatusCodes.Status400BadRequest)] 49 | [ProducesResponseType(StatusCodes.Status404NotFound)] 50 | public async Task PutTodoList(int id, TodoList todoList) 51 | { 52 | if (id != todoList.Id) 53 | { 54 | return BadRequest(); 55 | } 56 | 57 | _context.Entry(todoList).State = EntityState.Modified; 58 | 59 | try 60 | { 61 | await _context.SaveChangesAsync(); 62 | } 63 | catch (DbUpdateConcurrencyException) 64 | { 65 | if (!TodoListExists(id)) 66 | { 67 | return NotFound(); 68 | } 69 | else 70 | { 71 | throw; 72 | } 73 | } 74 | 75 | return NoContent(); 76 | } 77 | 78 | // POST: api/TodoLists 79 | // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 80 | [HttpPost] 81 | [ProducesResponseType(typeof(TodoList), StatusCodes.Status201Created)] 82 | public async Task> PostTodoList(TodoList todoList) 83 | { 84 | _context.TodoLists.Add(todoList); 85 | 86 | await _context.SaveChangesAsync(); 87 | 88 | return CreatedAtAction("GetTodoList", new { id = todoList.Id }, todoList); 89 | } 90 | 91 | // DELETE: api/TodoLists/5 92 | [HttpDelete("{id}")] 93 | [ProducesResponseType(StatusCodes.Status204NoContent)] 94 | [ProducesResponseType(StatusCodes.Status404NotFound)] 95 | public async Task DeleteTodoList(int id) 96 | { 97 | var todoList = await _context.TodoLists.FindAsync(id); 98 | if (todoList == null) 99 | { 100 | return NotFound(); 101 | } 102 | 103 | _context.TodoLists.Remove(todoList); 104 | await _context.SaveChangesAsync(); 105 | 106 | return NoContent(); 107 | } 108 | 109 | private bool TodoListExists(int id) 110 | { 111 | return _context.TodoLists.Any(e => e.Id == id); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Server/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 4 | 5 | namespace BlazorDemo.Server.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class ValuesController : ControllerBase 10 | { 11 | // GET: api/ 12 | [HttpGet] 13 | public IEnumerable Get() 14 | { 15 | return new string[] { "value1", "value2" }; 16 | } 17 | 18 | // GET api//5 19 | [HttpGet("{id}")] 20 | public string Get(int id) 21 | { 22 | return "value"; 23 | } 24 | 25 | // POST api/ 26 | [HttpPost] 27 | public void Post([FromBody] string value) 28 | { 29 | } 30 | 31 | // PUT api//5 32 | [HttpPut("{id}")] 33 | public void Put(int id, [FromBody] string value) 34 | { 35 | } 36 | 37 | // DELETE api//5 38 | [HttpDelete("{id}")] 39 | public void Delete(int id) 40 | { 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Server/Controllers/WeatherController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using BlazorDemo.Shared; 3 | 4 | namespace BlazorDemo.Server.Controllers; 5 | 6 | [ApiController] 7 | [Route("api/[controller]")] 8 | public class WeatherController : ControllerBase 9 | { 10 | private static readonly string[] Summaries = new[] 11 | { 12 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 13 | }; 14 | 15 | private readonly ILogger _logger; 16 | 17 | public WeatherController(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | [HttpGet] 23 | public IEnumerable Get() 24 | { 25 | Thread.Sleep(3000); 26 | 27 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 28 | { 29 | Date = DateTime.Now.AddDays(index), 30 | TemperatureC = Random.Shared.Next(-20, 55), 31 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 32 | }) 33 | .ToArray(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Server/Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using BlazorDemo.Shared; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace BlazorDemo.Server.Data; 5 | 6 | public class ApplicationDbContext : DbContext 7 | { 8 | public ApplicationDbContext(DbContextOptions options) 9 | : base(options) { } 10 | 11 | public DbSet TodoLists => Set(); 12 | 13 | public DbSet TodoItems => Set(); 14 | 15 | protected override void OnModelCreating(ModelBuilder modelBuilder) 16 | { 17 | base.OnModelCreating(modelBuilder); 18 | 19 | modelBuilder.Entity().HasData( 20 | new TodoList { Id = 1, Title = "Todo List" }); 21 | 22 | modelBuilder.Entity().HasData( 23 | new TodoItem { Id = 1, ListId = 1, Title = "Make a todo list" }, 24 | new TodoItem { Id = 2, ListId = 1, Title = "Check off the first item" }, 25 | new TodoItem { Id = 3, ListId = 1, Title = "Realise you've already done two things on the list!" }, 26 | new TodoItem { Id = 4, ListId = 1, Title = "Reward yourself with a nice, long nap" }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Server/Migrations/20211013104015_InitialCreate.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using BlazorDemo.Server.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 | 9 | #nullable disable 10 | 11 | namespace BlazorDemo.Server.Migrations 12 | { 13 | [DbContext(typeof(ApplicationDbContext))] 14 | [Migration("20211013104015_InitialCreate")] 15 | partial class InitialCreate 16 | { 17 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 18 | { 19 | #pragma warning disable 612, 618 20 | modelBuilder 21 | .HasAnnotation("ProductVersion", "6.0.0-rc.2.21480.5") 22 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 23 | 24 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); 25 | 26 | modelBuilder.Entity("BlazorDemo.Shared.TodoItem", b => 27 | { 28 | b.Property("Id") 29 | .ValueGeneratedOnAdd() 30 | .HasColumnType("int"); 31 | 32 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); 33 | 34 | b.Property("Done") 35 | .HasColumnType("bit"); 36 | 37 | b.Property("ListId") 38 | .HasColumnType("int"); 39 | 40 | b.Property("Note") 41 | .IsRequired() 42 | .HasColumnType("nvarchar(max)"); 43 | 44 | b.Property("Priority") 45 | .HasColumnType("int"); 46 | 47 | b.Property("State") 48 | .HasColumnType("int"); 49 | 50 | b.Property("Title") 51 | .IsRequired() 52 | .HasColumnType("nvarchar(max)"); 53 | 54 | b.HasKey("Id"); 55 | 56 | b.HasIndex("ListId"); 57 | 58 | b.ToTable("TodoItems"); 59 | 60 | b.HasData( 61 | new 62 | { 63 | Id = 1, 64 | Done = false, 65 | ListId = 1, 66 | Note = "", 67 | Priority = 0, 68 | State = 0, 69 | Title = "Make a todo list" 70 | }, 71 | new 72 | { 73 | Id = 2, 74 | Done = false, 75 | ListId = 1, 76 | Note = "", 77 | Priority = 0, 78 | State = 0, 79 | Title = "Check off the first item" 80 | }, 81 | new 82 | { 83 | Id = 3, 84 | Done = false, 85 | ListId = 1, 86 | Note = "", 87 | Priority = 0, 88 | State = 0, 89 | Title = "Realise you've already done two things on the list!" 90 | }, 91 | new 92 | { 93 | Id = 4, 94 | Done = false, 95 | ListId = 1, 96 | Note = "", 97 | Priority = 0, 98 | State = 0, 99 | Title = "Reward yourself with a nice, long nap" 100 | }); 101 | }); 102 | 103 | modelBuilder.Entity("BlazorDemo.Shared.TodoList", b => 104 | { 105 | b.Property("Id") 106 | .ValueGeneratedOnAdd() 107 | .HasColumnType("int"); 108 | 109 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); 110 | 111 | b.Property("Title") 112 | .IsRequired() 113 | .HasColumnType("nvarchar(max)"); 114 | 115 | b.HasKey("Id"); 116 | 117 | b.ToTable("TodoLists"); 118 | 119 | b.HasData( 120 | new 121 | { 122 | Id = 1, 123 | Title = "Todo List" 124 | }); 125 | }); 126 | 127 | modelBuilder.Entity("BlazorDemo.Shared.TodoItem", b => 128 | { 129 | b.HasOne("BlazorDemo.Shared.TodoList", "List") 130 | .WithMany("Items") 131 | .HasForeignKey("ListId") 132 | .OnDelete(DeleteBehavior.Cascade) 133 | .IsRequired(); 134 | 135 | b.Navigation("List"); 136 | }); 137 | 138 | modelBuilder.Entity("BlazorDemo.Shared.TodoList", b => 139 | { 140 | b.Navigation("Items"); 141 | }); 142 | #pragma warning restore 612, 618 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /Server/Migrations/20211013104015_InitialCreate.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | #nullable disable 4 | 5 | namespace BlazorDemo.Server.Migrations 6 | { 7 | public partial class InitialCreate : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.CreateTable( 12 | name: "TodoLists", 13 | columns: table => new 14 | { 15 | Id = table.Column(type: "int", nullable: false) 16 | .Annotation("SqlServer:Identity", "1, 1"), 17 | Title = table.Column(type: "nvarchar(max)", nullable: false) 18 | }, 19 | constraints: table => 20 | { 21 | table.PrimaryKey("PK_TodoLists", x => x.Id); 22 | }); 23 | 24 | migrationBuilder.CreateTable( 25 | name: "TodoItems", 26 | columns: table => new 27 | { 28 | Id = table.Column(type: "int", nullable: false) 29 | .Annotation("SqlServer:Identity", "1, 1"), 30 | ListId = table.Column(type: "int", nullable: false), 31 | Title = table.Column(type: "nvarchar(max)", nullable: false), 32 | Note = table.Column(type: "nvarchar(max)", nullable: false), 33 | Priority = table.Column(type: "int", nullable: false), 34 | State = table.Column(type: "int", nullable: false), 35 | Done = table.Column(type: "bit", nullable: false) 36 | }, 37 | constraints: table => 38 | { 39 | table.PrimaryKey("PK_TodoItems", x => x.Id); 40 | table.ForeignKey( 41 | name: "FK_TodoItems_TodoLists_ListId", 42 | column: x => x.ListId, 43 | principalTable: "TodoLists", 44 | principalColumn: "Id", 45 | onDelete: ReferentialAction.Cascade); 46 | }); 47 | 48 | migrationBuilder.InsertData( 49 | table: "TodoLists", 50 | columns: new[] { "Id", "Title" }, 51 | values: new object[] { 1, "Todo List" }); 52 | 53 | migrationBuilder.InsertData( 54 | table: "TodoItems", 55 | columns: new[] { "Id", "Done", "ListId", "Note", "Priority", "State", "Title" }, 56 | values: new object[,] 57 | { 58 | { 1, false, 1, "", 0, 0, "Make a todo list" }, 59 | { 2, false, 1, "", 0, 0, "Check off the first item" }, 60 | { 3, false, 1, "", 0, 0, "Realise you've already done two things on the list!" }, 61 | { 4, false, 1, "", 0, 0, "Reward yourself with a nice, long nap" } 62 | }); 63 | 64 | migrationBuilder.CreateIndex( 65 | name: "IX_TodoItems_ListId", 66 | table: "TodoItems", 67 | column: "ListId"); 68 | } 69 | 70 | protected override void Down(MigrationBuilder migrationBuilder) 71 | { 72 | migrationBuilder.DropTable( 73 | name: "TodoItems"); 74 | 75 | migrationBuilder.DropTable( 76 | name: "TodoLists"); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Server/Migrations/ApplicationDbContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using BlazorDemo.Server.Data; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 7 | 8 | #nullable disable 9 | 10 | namespace BlazorDemo.Server.Migrations 11 | { 12 | [DbContext(typeof(ApplicationDbContext))] 13 | partial class ApplicationDbContextModelSnapshot : ModelSnapshot 14 | { 15 | protected override void BuildModel(ModelBuilder modelBuilder) 16 | { 17 | #pragma warning disable 612, 618 18 | modelBuilder 19 | .HasAnnotation("ProductVersion", "6.0.0-rc.2.21480.5") 20 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 21 | 22 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); 23 | 24 | modelBuilder.Entity("BlazorDemo.Shared.TodoItem", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("int"); 29 | 30 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); 31 | 32 | b.Property("Done") 33 | .HasColumnType("bit"); 34 | 35 | b.Property("ListId") 36 | .HasColumnType("int"); 37 | 38 | b.Property("Note") 39 | .IsRequired() 40 | .HasColumnType("nvarchar(max)"); 41 | 42 | b.Property("Priority") 43 | .HasColumnType("int"); 44 | 45 | b.Property("State") 46 | .HasColumnType("int"); 47 | 48 | b.Property("Title") 49 | .IsRequired() 50 | .HasColumnType("nvarchar(max)"); 51 | 52 | b.HasKey("Id"); 53 | 54 | b.HasIndex("ListId"); 55 | 56 | b.ToTable("TodoItems"); 57 | 58 | b.HasData( 59 | new 60 | { 61 | Id = 1, 62 | Done = false, 63 | ListId = 1, 64 | Note = "", 65 | Priority = 0, 66 | State = 0, 67 | Title = "Make a todo list" 68 | }, 69 | new 70 | { 71 | Id = 2, 72 | Done = false, 73 | ListId = 1, 74 | Note = "", 75 | Priority = 0, 76 | State = 0, 77 | Title = "Check off the first item" 78 | }, 79 | new 80 | { 81 | Id = 3, 82 | Done = false, 83 | ListId = 1, 84 | Note = "", 85 | Priority = 0, 86 | State = 0, 87 | Title = "Realise you've already done two things on the list!" 88 | }, 89 | new 90 | { 91 | Id = 4, 92 | Done = false, 93 | ListId = 1, 94 | Note = "", 95 | Priority = 0, 96 | State = 0, 97 | Title = "Reward yourself with a nice, long nap" 98 | }); 99 | }); 100 | 101 | modelBuilder.Entity("BlazorDemo.Shared.TodoList", b => 102 | { 103 | b.Property("Id") 104 | .ValueGeneratedOnAdd() 105 | .HasColumnType("int"); 106 | 107 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); 108 | 109 | b.Property("Title") 110 | .IsRequired() 111 | .HasColumnType("nvarchar(max)"); 112 | 113 | b.HasKey("Id"); 114 | 115 | b.ToTable("TodoLists"); 116 | 117 | b.HasData( 118 | new 119 | { 120 | Id = 1, 121 | Title = "Todo List" 122 | }); 123 | }); 124 | 125 | modelBuilder.Entity("BlazorDemo.Shared.TodoItem", b => 126 | { 127 | b.HasOne("BlazorDemo.Shared.TodoList", "List") 128 | .WithMany("Items") 129 | .HasForeignKey("ListId") 130 | .OnDelete(DeleteBehavior.Cascade) 131 | .IsRequired(); 132 | 133 | b.Navigation("List"); 134 | }); 135 | 136 | modelBuilder.Entity("BlazorDemo.Shared.TodoList", b => 137 | { 138 | b.Navigation("Items"); 139 | }); 140 | #pragma warning restore 612, 618 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Server/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model BlazorDemo.Server.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Server/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.AspNetCore.Mvc.RazorPages; 4 | 5 | namespace BlazorDemo.Server.Pages; 6 | 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | [IgnoreAntiforgeryToken] 9 | public class ErrorModel : PageModel 10 | { 11 | public string RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Server/Program.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorDemo.Server; 2 | 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | CreateHostBuilder(args).Build().Run(); 8 | } 9 | 10 | public static IHostBuilder CreateHostBuilder(string[] args) => 11 | Host.CreateDefaultBuilder(args) 12 | .ConfigureWebHostDefaults(webBuilder => 13 | { 14 | webBuilder.UseStartup(); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:32755", 7 | "sslPort": 44318 8 | } 9 | }, 10 | "profiles": { 11 | "BlazorDemo.Server": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 16 | "applicationUrl": "https://localhost:7270;http://localhost:5194", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Server/Startup.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using BlazorDemo.Server.Data; 3 | using BlazorDemo.Server.Validators; 4 | using FluentValidation.AspNetCore; 5 | using Microsoft.EntityFrameworkCore; 6 | 7 | namespace BlazorDemo.Server; 8 | 9 | public class Startup 10 | { 11 | public Startup(IConfiguration configuration) 12 | { 13 | Configuration = configuration; 14 | } 15 | 16 | public IConfiguration Configuration { get; } 17 | 18 | public void ConfigureServices(IServiceCollection services) 19 | { 20 | var connectionString = Configuration.GetConnectionString("DefaultConnection"); 21 | 22 | services.AddDbContext(options => 23 | options.UseSqlServer(connectionString)); 24 | 25 | services.AddDatabaseDeveloperPageExceptionFilter(); 26 | 27 | services.AddControllersWithViews() 28 | .AddFluentValidation(config => 29 | config.RegisterValidatorsFromAssemblyContaining()) 30 | .AddJsonOptions(config => 31 | config.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles); 32 | 33 | services.AddRazorPages(); 34 | 35 | services.AddOpenApiDocument(configure => 36 | { 37 | configure.Title = "BlazorDemo API"; 38 | }); 39 | } 40 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 41 | { 42 | // Configure the HTTP request pipeline. 43 | if (env.IsDevelopment()) 44 | { 45 | app.UseMigrationsEndPoint(); 46 | app.UseWebAssemblyDebugging(); 47 | } 48 | else 49 | { 50 | app.UseExceptionHandler("/Error"); 51 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 52 | app.UseHsts(); 53 | } 54 | 55 | app.UseHttpsRedirection(); 56 | 57 | app.UseBlazorFrameworkFiles(); 58 | app.UseStaticFiles(); 59 | 60 | app.UseSwaggerUi3(configure => 61 | configure.DocumentPath = "/api/v1/specification.json"); 62 | 63 | app.UseRouting(); 64 | 65 | app.UseEndpoints(endpoints => 66 | { 67 | endpoints.MapRazorPages(); 68 | endpoints.MapControllers(); 69 | endpoints.MapFallbackToFile("index.html"); 70 | }); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Server/Validators/TodoListValidator.cs: -------------------------------------------------------------------------------- 1 | using BlazorDemo.Server.Data; 2 | using BlazorDemo.Shared; 3 | using FluentValidation; 4 | using Microsoft.EntityFrameworkCore; 5 | 6 | namespace BlazorDemo.Server.Validators 7 | { 8 | public class TodoListValidator : Shared.TodoListValidator 9 | { 10 | private readonly ApplicationDbContext _context; 11 | 12 | public TodoListValidator(ApplicationDbContext context) : base() 13 | { 14 | _context = context; 15 | 16 | RuleFor(v => v.Title) 17 | .MustAsync(BeUniqueTitle) 18 | .WithMessage("'Title' must be unique."); 19 | } 20 | 21 | public async Task BeUniqueTitle(TodoList list, string title, CancellationToken cancellationToken) 22 | { 23 | return await _context.TodoLists 24 | .Where(tl => tl.Id != list.Id) 25 | .AllAsync(tl => tl.Title != title, cancellationToken); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Server/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=BlazorDemo;Trusted_Connection=True;MultipleActiveResultSets=true" 4 | }, 5 | "Logging": { 6 | "LogLevel": { 7 | "Default": "Information", 8 | "Microsoft.AspNetCore": "Warning" 9 | } 10 | }, 11 | "AllowedHosts": "*" 12 | } 13 | -------------------------------------------------------------------------------- /Server/config.nswag: -------------------------------------------------------------------------------- 1 | { 2 | "runtime": "Net50", 3 | "defaultVariables": null, 4 | "documentGenerator": { 5 | "aspNetCoreToOpenApi": { 6 | "project": "BlazorDemo.Server.csproj", 7 | "msBuildProjectExtensionsPath": null, 8 | "configuration": null, 9 | "runtime": null, 10 | "targetFramework": null, 11 | "noBuild": true, 12 | "msBuildOutputPath": null, 13 | "verbose": true, 14 | "workingDirectory": null, 15 | "requireParametersWithoutDefault": false, 16 | "apiGroupNames": null, 17 | "defaultPropertyNameHandling": "Default", 18 | "defaultReferenceTypeNullHandling": "Null", 19 | "defaultDictionaryValueReferenceTypeNullHandling": "NotNull", 20 | "defaultResponseReferenceTypeNullHandling": "NotNull", 21 | "generateOriginalParameterNames": true, 22 | "defaultEnumHandling": "Integer", 23 | "flattenInheritanceHierarchy": false, 24 | "generateKnownTypes": true, 25 | "generateEnumMappingDescription": false, 26 | "generateXmlObjects": false, 27 | "generateAbstractProperties": false, 28 | "generateAbstractSchemas": true, 29 | "ignoreObsoleteProperties": false, 30 | "allowReferencesWithProperties": false, 31 | "excludedTypeNames": [], 32 | "serviceHost": null, 33 | "serviceBasePath": null, 34 | "serviceSchemes": [], 35 | "infoTitle": "My Title", 36 | "infoDescription": null, 37 | "infoVersion": "1.0.0", 38 | "documentTemplate": null, 39 | "documentProcessorTypes": [], 40 | "operationProcessorTypes": [], 41 | "typeNameGeneratorType": null, 42 | "schemaNameGeneratorType": null, 43 | "contractResolverType": null, 44 | "serializerSettingsType": null, 45 | "useDocumentProvider": true, 46 | "documentName": "v1", 47 | "aspNetCoreEnvironment": null, 48 | "allowNullableBodyParameters": true, 49 | "useHttpAttributeNameAsOperationId": false, 50 | "output": "wwwroot/api/v1/specification.json", 51 | "outputType": "OpenApi3", 52 | "newLineBehavior": "Auto", 53 | "assemblyPaths": [], 54 | "assemblyConfig": null, 55 | "referencePaths": [], 56 | "useNuGetCache": false 57 | } 58 | }, 59 | "codeGenerators": { 60 | "openApiToCSharpClient": { 61 | "clientBaseClass": null, 62 | "configurationClass": null, 63 | "generateClientClasses": true, 64 | "generateClientInterfaces": true, 65 | "clientBaseInterface": null, 66 | "injectHttpClient": true, 67 | "disposeHttpClient": true, 68 | "protectedMethods": [], 69 | "generateExceptionClasses": true, 70 | "exceptionClass": "ApiException", 71 | "wrapDtoExceptions": true, 72 | "useHttpClientCreationMethod": false, 73 | "httpClientType": "System.Net.Http.HttpClient", 74 | "useHttpRequestMessageCreationMethod": false, 75 | "useBaseUrl": false, 76 | "generateBaseUrlProperty": true, 77 | "generateSyncMethods": false, 78 | "generatePrepareRequestAndProcessResponseAsAsyncMethods": false, 79 | "exposeJsonSerializerSettings": false, 80 | "clientClassAccessModifier": "public", 81 | "typeAccessModifier": "public", 82 | "generateContractsOutput": false, 83 | "contractsNamespace": null, 84 | "contractsOutputFilePath": null, 85 | "parameterDateTimeFormat": "s", 86 | "parameterDateFormat": "yyyy-MM-dd", 87 | "generateUpdateJsonSerializerSettingsMethod": true, 88 | "useRequestAndResponseSerializationSettings": false, 89 | "serializeTypeInformation": false, 90 | "queryNullValue": "", 91 | "className": "{controller}Client", 92 | "operationGenerationMode": "MultipleClientsFromOperationId", 93 | "additionalNamespaceUsages": [ 94 | "Microsoft.AspNetCore.Mvc", 95 | "BlazorDemo.Shared" 96 | ], 97 | "additionalContractNamespaceUsages": [], 98 | "generateOptionalParameters": false, 99 | "generateJsonMethods": false, 100 | "enforceFlagEnums": false, 101 | "parameterArrayType": "System.Collections.Generic.IEnumerable", 102 | "parameterDictionaryType": "System.Collections.Generic.IDictionary", 103 | "responseArrayType": "System.Collections.Generic.ICollection", 104 | "responseDictionaryType": "System.Collections.Generic.IDictionary", 105 | "wrapResponses": false, 106 | "wrapResponseMethods": [], 107 | "generateResponseClasses": true, 108 | "responseClass": "SwaggerResponse", 109 | "namespace": "BlazorDemo.Client", 110 | "requiredPropertiesMustBeDefined": true, 111 | "dateType": "System.DateTimeOffset", 112 | "jsonConverters": null, 113 | "anyType": "object", 114 | "dateTimeType": "System.DateTimeOffset", 115 | "timeType": "System.TimeSpan", 116 | "timeSpanType": "System.TimeSpan", 117 | "arrayType": "System.Collections.Generic.ICollection", 118 | "arrayInstanceType": "System.Collections.ObjectModel.Collection", 119 | "dictionaryType": "System.Collections.Generic.IDictionary", 120 | "dictionaryInstanceType": "System.Collections.Generic.Dictionary", 121 | "arrayBaseType": "System.Collections.ObjectModel.Collection", 122 | "dictionaryBaseType": "System.Collections.Generic.Dictionary", 123 | "classStyle": "Poco", 124 | "jsonLibrary": "NewtonsoftJson", 125 | "generateDefaultValues": true, 126 | "generateDataAnnotations": true, 127 | "excludedTypeNames": [], 128 | "excludedParameterNames": [], 129 | "handleReferences": false, 130 | "generateImmutableArrayProperties": false, 131 | "generateImmutableDictionaryProperties": false, 132 | "jsonSerializerSettingsTransformationMethod": null, 133 | "inlineNamedArrays": false, 134 | "inlineNamedDictionaries": false, 135 | "inlineNamedTuples": true, 136 | "inlineNamedAny": false, 137 | "generateDtoTypes": false, 138 | "generateOptionalPropertiesAsNullable": false, 139 | "generateNullableReferenceTypes": false, 140 | "templateDirectory": null, 141 | "typeNameGeneratorType": null, 142 | "propertyNameGeneratorType": null, 143 | "enumNameGeneratorType": null, 144 | "checksumCacheEnabled": false, 145 | "serviceHost": null, 146 | "serviceSchemes": null, 147 | "output": "../Client/Services/BlazorDemoApiClients.g.cs", 148 | "newLineBehavior": "Auto" 149 | } 150 | } 151 | } -------------------------------------------------------------------------------- /Server/wwwroot/api/v1/specification.json: -------------------------------------------------------------------------------- 1 | { 2 | "x-generator": "NSwag v13.13.2.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v13.0.0.0))", 3 | "openapi": "3.0.0", 4 | "info": { 5 | "title": "BlazorDemo API", 6 | "version": "1.0.0" 7 | }, 8 | "paths": { 9 | "/api/TodoItems/{id}": { 10 | "get": { 11 | "tags": [ 12 | "TodoItems" 13 | ], 14 | "operationId": "TodoItems_GetTodoItem", 15 | "parameters": [ 16 | { 17 | "name": "id", 18 | "in": "path", 19 | "required": true, 20 | "schema": { 21 | "type": "integer", 22 | "format": "int32" 23 | }, 24 | "x-position": 1 25 | } 26 | ], 27 | "responses": { 28 | "200": { 29 | "description": "", 30 | "content": { 31 | "application/json": { 32 | "schema": { 33 | "$ref": "#/components/schemas/TodoItem" 34 | } 35 | } 36 | } 37 | }, 38 | "404": { 39 | "description": "", 40 | "content": { 41 | "application/json": { 42 | "schema": { 43 | "$ref": "#/components/schemas/ProblemDetails" 44 | } 45 | } 46 | } 47 | } 48 | } 49 | }, 50 | "put": { 51 | "tags": [ 52 | "TodoItems" 53 | ], 54 | "operationId": "TodoItems_PutTodoItem", 55 | "parameters": [ 56 | { 57 | "name": "id", 58 | "in": "path", 59 | "required": true, 60 | "schema": { 61 | "type": "integer", 62 | "format": "int32" 63 | }, 64 | "x-position": 1 65 | } 66 | ], 67 | "requestBody": { 68 | "x-name": "todoItem", 69 | "content": { 70 | "application/json": { 71 | "schema": { 72 | "$ref": "#/components/schemas/TodoItem" 73 | } 74 | } 75 | }, 76 | "required": true, 77 | "x-position": 2 78 | }, 79 | "responses": { 80 | "204": { 81 | "description": "" 82 | }, 83 | "400": { 84 | "description": "", 85 | "content": { 86 | "application/json": { 87 | "schema": { 88 | "$ref": "#/components/schemas/ProblemDetails" 89 | } 90 | } 91 | } 92 | }, 93 | "404": { 94 | "description": "", 95 | "content": { 96 | "application/json": { 97 | "schema": { 98 | "$ref": "#/components/schemas/ProblemDetails" 99 | } 100 | } 101 | } 102 | } 103 | } 104 | }, 105 | "delete": { 106 | "tags": [ 107 | "TodoItems" 108 | ], 109 | "operationId": "TodoItems_DeleteTodoItem", 110 | "parameters": [ 111 | { 112 | "name": "id", 113 | "in": "path", 114 | "required": true, 115 | "schema": { 116 | "type": "integer", 117 | "format": "int32" 118 | }, 119 | "x-position": 1 120 | } 121 | ], 122 | "responses": { 123 | "204": { 124 | "description": "" 125 | }, 126 | "404": { 127 | "description": "", 128 | "content": { 129 | "application/json": { 130 | "schema": { 131 | "$ref": "#/components/schemas/ProblemDetails" 132 | } 133 | } 134 | } 135 | } 136 | } 137 | } 138 | }, 139 | "/api/TodoItems": { 140 | "post": { 141 | "tags": [ 142 | "TodoItems" 143 | ], 144 | "operationId": "TodoItems_PostTodoItem", 145 | "requestBody": { 146 | "x-name": "todoItem", 147 | "content": { 148 | "application/json": { 149 | "schema": { 150 | "$ref": "#/components/schemas/TodoItem" 151 | } 152 | } 153 | }, 154 | "required": true, 155 | "x-position": 1 156 | }, 157 | "responses": { 158 | "201": { 159 | "description": "", 160 | "content": { 161 | "application/json": { 162 | "schema": { 163 | "$ref": "#/components/schemas/TodoItem" 164 | } 165 | } 166 | } 167 | } 168 | } 169 | } 170 | }, 171 | "/api/TodoLists": { 172 | "get": { 173 | "tags": [ 174 | "TodoLists" 175 | ], 176 | "operationId": "TodoLists_GetTodoLists", 177 | "responses": { 178 | "200": { 179 | "description": "", 180 | "content": { 181 | "application/json": { 182 | "schema": { 183 | "type": "array", 184 | "items": { 185 | "$ref": "#/components/schemas/TodoList" 186 | } 187 | } 188 | } 189 | } 190 | } 191 | } 192 | }, 193 | "post": { 194 | "tags": [ 195 | "TodoLists" 196 | ], 197 | "operationId": "TodoLists_PostTodoList", 198 | "requestBody": { 199 | "x-name": "todoList", 200 | "content": { 201 | "application/json": { 202 | "schema": { 203 | "$ref": "#/components/schemas/TodoList" 204 | } 205 | } 206 | }, 207 | "required": true, 208 | "x-position": 1 209 | }, 210 | "responses": { 211 | "201": { 212 | "description": "", 213 | "content": { 214 | "application/json": { 215 | "schema": { 216 | "$ref": "#/components/schemas/TodoList" 217 | } 218 | } 219 | } 220 | } 221 | } 222 | } 223 | }, 224 | "/api/TodoLists/{id}": { 225 | "get": { 226 | "tags": [ 227 | "TodoLists" 228 | ], 229 | "operationId": "TodoLists_GetTodoList", 230 | "parameters": [ 231 | { 232 | "name": "id", 233 | "in": "path", 234 | "required": true, 235 | "schema": { 236 | "type": "integer", 237 | "format": "int32" 238 | }, 239 | "x-position": 1 240 | } 241 | ], 242 | "responses": { 243 | "200": { 244 | "description": "", 245 | "content": { 246 | "application/json": { 247 | "schema": { 248 | "$ref": "#/components/schemas/TodoList" 249 | } 250 | } 251 | } 252 | }, 253 | "404": { 254 | "description": "", 255 | "content": { 256 | "application/json": { 257 | "schema": { 258 | "$ref": "#/components/schemas/ProblemDetails" 259 | } 260 | } 261 | } 262 | } 263 | } 264 | }, 265 | "put": { 266 | "tags": [ 267 | "TodoLists" 268 | ], 269 | "operationId": "TodoLists_PutTodoList", 270 | "parameters": [ 271 | { 272 | "name": "id", 273 | "in": "path", 274 | "required": true, 275 | "schema": { 276 | "type": "integer", 277 | "format": "int32" 278 | }, 279 | "x-position": 1 280 | } 281 | ], 282 | "requestBody": { 283 | "x-name": "todoList", 284 | "content": { 285 | "application/json": { 286 | "schema": { 287 | "$ref": "#/components/schemas/TodoList" 288 | } 289 | } 290 | }, 291 | "required": true, 292 | "x-position": 2 293 | }, 294 | "responses": { 295 | "204": { 296 | "description": "" 297 | }, 298 | "400": { 299 | "description": "", 300 | "content": { 301 | "application/json": { 302 | "schema": { 303 | "$ref": "#/components/schemas/ProblemDetails" 304 | } 305 | } 306 | } 307 | }, 308 | "404": { 309 | "description": "", 310 | "content": { 311 | "application/json": { 312 | "schema": { 313 | "$ref": "#/components/schemas/ProblemDetails" 314 | } 315 | } 316 | } 317 | } 318 | } 319 | }, 320 | "delete": { 321 | "tags": [ 322 | "TodoLists" 323 | ], 324 | "operationId": "TodoLists_DeleteTodoList", 325 | "parameters": [ 326 | { 327 | "name": "id", 328 | "in": "path", 329 | "required": true, 330 | "schema": { 331 | "type": "integer", 332 | "format": "int32" 333 | }, 334 | "x-position": 1 335 | } 336 | ], 337 | "responses": { 338 | "204": { 339 | "description": "" 340 | }, 341 | "404": { 342 | "description": "", 343 | "content": { 344 | "application/json": { 345 | "schema": { 346 | "$ref": "#/components/schemas/ProblemDetails" 347 | } 348 | } 349 | } 350 | } 351 | } 352 | } 353 | }, 354 | "/api/Values": { 355 | "get": { 356 | "tags": [ 357 | "Values" 358 | ], 359 | "operationId": "Values_GetAll", 360 | "responses": { 361 | "200": { 362 | "description": "", 363 | "content": { 364 | "application/json": { 365 | "schema": { 366 | "type": "array", 367 | "items": { 368 | "type": "string" 369 | } 370 | } 371 | } 372 | } 373 | } 374 | } 375 | }, 376 | "post": { 377 | "tags": [ 378 | "Values" 379 | ], 380 | "operationId": "Values_Post", 381 | "requestBody": { 382 | "x-name": "value", 383 | "content": { 384 | "application/json": { 385 | "schema": { 386 | "type": "string" 387 | } 388 | } 389 | }, 390 | "required": true, 391 | "x-position": 1 392 | }, 393 | "responses": { 394 | "200": { 395 | "description": "" 396 | } 397 | } 398 | } 399 | }, 400 | "/api/Values/{id}": { 401 | "get": { 402 | "tags": [ 403 | "Values" 404 | ], 405 | "operationId": "Values_Get", 406 | "parameters": [ 407 | { 408 | "name": "id", 409 | "in": "path", 410 | "required": true, 411 | "schema": { 412 | "type": "integer", 413 | "format": "int32" 414 | }, 415 | "x-position": 1 416 | } 417 | ], 418 | "responses": { 419 | "200": { 420 | "description": "", 421 | "content": { 422 | "application/json": { 423 | "schema": { 424 | "type": "string" 425 | } 426 | } 427 | } 428 | } 429 | } 430 | }, 431 | "put": { 432 | "tags": [ 433 | "Values" 434 | ], 435 | "operationId": "Values_Put", 436 | "parameters": [ 437 | { 438 | "name": "id", 439 | "in": "path", 440 | "required": true, 441 | "schema": { 442 | "type": "integer", 443 | "format": "int32" 444 | }, 445 | "x-position": 1 446 | } 447 | ], 448 | "requestBody": { 449 | "x-name": "value", 450 | "content": { 451 | "application/json": { 452 | "schema": { 453 | "type": "string" 454 | } 455 | } 456 | }, 457 | "required": true, 458 | "x-position": 2 459 | }, 460 | "responses": { 461 | "200": { 462 | "description": "" 463 | } 464 | } 465 | }, 466 | "delete": { 467 | "tags": [ 468 | "Values" 469 | ], 470 | "operationId": "Values_Delete", 471 | "parameters": [ 472 | { 473 | "name": "id", 474 | "in": "path", 475 | "required": true, 476 | "schema": { 477 | "type": "integer", 478 | "format": "int32" 479 | }, 480 | "x-position": 1 481 | } 482 | ], 483 | "responses": { 484 | "200": { 485 | "description": "" 486 | } 487 | } 488 | } 489 | }, 490 | "/api/Weather": { 491 | "get": { 492 | "tags": [ 493 | "Weather" 494 | ], 495 | "operationId": "Weather_Get", 496 | "responses": { 497 | "200": { 498 | "description": "", 499 | "content": { 500 | "application/json": { 501 | "schema": { 502 | "type": "array", 503 | "items": { 504 | "$ref": "#/components/schemas/WeatherForecast" 505 | } 506 | } 507 | } 508 | } 509 | } 510 | } 511 | } 512 | } 513 | }, 514 | "components": { 515 | "schemas": { 516 | "TodoItem": { 517 | "type": "object", 518 | "additionalProperties": false, 519 | "properties": { 520 | "id": { 521 | "type": "integer", 522 | "format": "int32" 523 | }, 524 | "listId": { 525 | "type": "integer", 526 | "format": "int32" 527 | }, 528 | "title": { 529 | "type": "string", 530 | "nullable": true 531 | }, 532 | "note": { 533 | "type": "string", 534 | "nullable": true 535 | }, 536 | "priority": { 537 | "$ref": "#/components/schemas/TodoItemPriority" 538 | }, 539 | "state": { 540 | "$ref": "#/components/schemas/TodoItemState" 541 | }, 542 | "done": { 543 | "type": "boolean" 544 | }, 545 | "list": { 546 | "nullable": true, 547 | "oneOf": [ 548 | { 549 | "$ref": "#/components/schemas/TodoList" 550 | } 551 | ] 552 | } 553 | } 554 | }, 555 | "TodoItemPriority": { 556 | "type": "integer", 557 | "description": "", 558 | "x-enumNames": [ 559 | "None", 560 | "Low", 561 | "Medium", 562 | "High" 563 | ], 564 | "enum": [ 565 | 0, 566 | 1, 567 | 2, 568 | 3 569 | ] 570 | }, 571 | "TodoItemState": { 572 | "type": "integer", 573 | "description": "", 574 | "x-enumNames": [ 575 | "NotStarted", 576 | "InProgress", 577 | "Blocked", 578 | "Done" 579 | ], 580 | "enum": [ 581 | 0, 582 | 1, 583 | 2, 584 | 3 585 | ] 586 | }, 587 | "TodoList": { 588 | "type": "object", 589 | "additionalProperties": false, 590 | "properties": { 591 | "id": { 592 | "type": "integer", 593 | "format": "int32" 594 | }, 595 | "title": { 596 | "type": "string", 597 | "nullable": true 598 | }, 599 | "items": { 600 | "type": "array", 601 | "nullable": true, 602 | "items": { 603 | "$ref": "#/components/schemas/TodoItem" 604 | } 605 | } 606 | } 607 | }, 608 | "ProblemDetails": { 609 | "type": "object", 610 | "additionalProperties": { 611 | "nullable": true 612 | }, 613 | "properties": { 614 | "type": { 615 | "type": "string", 616 | "nullable": true 617 | }, 618 | "title": { 619 | "type": "string", 620 | "nullable": true 621 | }, 622 | "status": { 623 | "type": "integer", 624 | "format": "int32", 625 | "nullable": true 626 | }, 627 | "detail": { 628 | "type": "string", 629 | "nullable": true 630 | }, 631 | "instance": { 632 | "type": "string", 633 | "nullable": true 634 | }, 635 | "extensions": { 636 | "type": "object", 637 | "additionalProperties": {} 638 | } 639 | } 640 | }, 641 | "WeatherForecast": { 642 | "type": "object", 643 | "additionalProperties": false, 644 | "properties": { 645 | "date": { 646 | "type": "string", 647 | "format": "date-time" 648 | }, 649 | "temperatureC": { 650 | "type": "integer", 651 | "format": "int32" 652 | }, 653 | "summary": { 654 | "type": "string", 655 | "nullable": true 656 | }, 657 | "temperatureF": { 658 | "type": "integer", 659 | "format": "int32" 660 | } 661 | } 662 | } 663 | } 664 | } 665 | } -------------------------------------------------------------------------------- /Shared/BlazorDemo.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Shared/TodoItem.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorDemo.Shared; 2 | 3 | public class TodoItem 4 | { 5 | public int Id { get; set; } 6 | 7 | public int ListId { get; set; } 8 | 9 | public string Title { get; set; } = string.Empty; 10 | 11 | public string Note { get; set; } = string.Empty; 12 | 13 | public TodoItemPriority Priority { get; set; } 14 | 15 | public TodoItemState State { get; set; } 16 | 17 | public bool Done { get; set; } 18 | 19 | public TodoList List { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /Shared/TodoItemPriority.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorDemo.Shared; 2 | 3 | public enum TodoItemPriority 4 | { 5 | None, 6 | Low, 7 | Medium, 8 | High 9 | } 10 | -------------------------------------------------------------------------------- /Shared/TodoItemState.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorDemo.Shared; 2 | 3 | public enum TodoItemState 4 | { 5 | NotStarted, 6 | InProgress, 7 | Blocked, 8 | Done 9 | } 10 | -------------------------------------------------------------------------------- /Shared/TodoList.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorDemo.Shared; 2 | 3 | public class TodoList 4 | { 5 | public int Id { get; set; } 6 | 7 | public string Title { get; set; } = string.Empty; 8 | 9 | public ICollection Items { get; set; } = new List(); 10 | } 11 | -------------------------------------------------------------------------------- /Shared/TodoListValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace BlazorDemo.Shared 4 | { 5 | public class TodoListValidator : AbstractValidator 6 | { 7 | public TodoListValidator() 8 | { 9 | RuleFor(p => p.Title) 10 | .NotEmpty(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Shared/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorDemo.Shared; 2 | 3 | public class WeatherForecast 4 | { 5 | public DateTime Date { get; set; } 6 | 7 | public int TemperatureC { get; set; } 8 | 9 | public string Summary { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | } 13 | --------------------------------------------------------------------------------