├── .github └── workflows │ └── build-validation.yml ├── .gitignore ├── Final_Project ├── RazorPagesMovie.sln └── RazorPagesMovie │ ├── Data │ └── RazorPagesMovieContext.cs │ ├── Migrations │ ├── 20230411061819_Initial.Designer.cs │ ├── 20230411061819_Initial.cs │ └── RazorPagesMovieContextModelSnapshot.cs │ ├── Models │ └── Movie.cs │ ├── MvcMovie.db │ ├── Pages │ ├── Error.cshtml │ ├── Error.cshtml.cs │ ├── Index.cshtml │ ├── Index.cshtml.cs │ ├── Movies │ │ ├── Create.cshtml │ │ ├── Create.cshtml.cs │ │ ├── Delete.cshtml │ │ ├── Delete.cshtml.cs │ │ ├── Details.cshtml │ │ ├── Details.cshtml.cs │ │ ├── Edit.cshtml │ │ ├── Edit.cshtml.cs │ │ ├── Index.cshtml │ │ └── Index.cshtml.cs │ ├── Privacy.cshtml │ ├── Privacy.cshtml.cs │ ├── Shared │ │ ├── _Layout.cshtml │ │ ├── _Layout.cshtml.css │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── Program.cs │ ├── Properties │ ├── serviceDependencies.json │ └── serviceDependencies.local.json │ ├── RazorPagesMovie.csproj │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-grid.rtl.css │ │ ├── bootstrap-grid.rtl.css.map │ │ ├── bootstrap-grid.rtl.min.css │ │ ├── bootstrap-grid.rtl.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap-reboot.rtl.css │ │ ├── bootstrap-reboot.rtl.css.map │ │ ├── bootstrap-reboot.rtl.min.css │ │ ├── bootstrap-reboot.rtl.min.css.map │ │ ├── bootstrap-utilities.css │ │ ├── bootstrap-utilities.css.map │ │ ├── bootstrap-utilities.min.css │ │ ├── bootstrap-utilities.min.css.map │ │ ├── bootstrap-utilities.rtl.css │ │ ├── bootstrap-utilities.rtl.css.map │ │ ├── bootstrap-utilities.rtl.min.css │ │ ├── bootstrap-utilities.rtl.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ ├── bootstrap.min.css.map │ │ ├── bootstrap.rtl.css │ │ ├── bootstrap.rtl.css.map │ │ ├── bootstrap.rtl.min.css │ │ └── bootstrap.rtl.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.esm.js │ │ ├── bootstrap.esm.js.map │ │ ├── bootstrap.esm.min.js │ │ ├── bootstrap.esm.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── LICENSE ├── README.md ├── Tutorial ├── 1-Create a Razor Page │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ ├── Create-a-Razorpage-VS.md │ ├── Create-a-Razorpage-VSMac.md │ ├── Create-a-Razorpage.md │ ├── RazorPagesMovie.sln │ ├── RazorPagesMovie │ │ ├── Pages │ │ │ ├── Error.cshtml │ │ │ ├── Error.cshtml.cs │ │ │ ├── Index.cshtml │ │ │ ├── Index.cshtml.cs │ │ │ ├── Privacy.cshtml │ │ │ ├── Privacy.cshtml.cs │ │ │ ├── Shared │ │ │ │ ├── _Layout.cshtml │ │ │ │ ├── _Layout.cshtml.css │ │ │ │ └── _ValidationScriptsPartial.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ └── _ViewStart.cshtml │ │ ├── Program.cs │ │ ├── RazorPagesMovie.csproj │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ ├── css │ │ │ └── site.css │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ └── site.js │ │ │ └── lib │ │ │ ├── bootstrap │ │ │ ├── LICENSE │ │ │ └── dist │ │ │ │ ├── css │ │ │ │ ├── bootstrap-grid.css │ │ │ │ ├── bootstrap-grid.css.map │ │ │ │ ├── bootstrap-grid.min.css │ │ │ │ ├── bootstrap-grid.min.css.map │ │ │ │ ├── bootstrap-grid.rtl.css │ │ │ │ ├── bootstrap-grid.rtl.css.map │ │ │ │ ├── bootstrap-grid.rtl.min.css │ │ │ │ ├── bootstrap-grid.rtl.min.css.map │ │ │ │ ├── bootstrap-reboot.css │ │ │ │ ├── bootstrap-reboot.css.map │ │ │ │ ├── bootstrap-reboot.min.css │ │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ │ ├── bootstrap-reboot.rtl.css │ │ │ │ ├── bootstrap-reboot.rtl.css.map │ │ │ │ ├── bootstrap-reboot.rtl.min.css │ │ │ │ ├── bootstrap-reboot.rtl.min.css.map │ │ │ │ ├── bootstrap-utilities.css │ │ │ │ ├── bootstrap-utilities.css.map │ │ │ │ ├── bootstrap-utilities.min.css │ │ │ │ ├── bootstrap-utilities.min.css.map │ │ │ │ ├── bootstrap-utilities.rtl.css │ │ │ │ ├── bootstrap-utilities.rtl.css.map │ │ │ │ ├── bootstrap-utilities.rtl.min.css │ │ │ │ ├── bootstrap-utilities.rtl.min.css.map │ │ │ │ ├── bootstrap.css │ │ │ │ ├── bootstrap.css.map │ │ │ │ ├── bootstrap.min.css │ │ │ │ ├── bootstrap.min.css.map │ │ │ │ ├── bootstrap.rtl.css │ │ │ │ ├── bootstrap.rtl.css.map │ │ │ │ ├── bootstrap.rtl.min.css │ │ │ │ └── bootstrap.rtl.min.css.map │ │ │ │ └── js │ │ │ │ ├── bootstrap.bundle.js │ │ │ │ ├── bootstrap.bundle.js.map │ │ │ │ ├── bootstrap.bundle.min.js │ │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ │ ├── bootstrap.esm.js │ │ │ │ ├── bootstrap.esm.js.map │ │ │ │ ├── bootstrap.esm.min.js │ │ │ │ ├── bootstrap.esm.min.js.map │ │ │ │ ├── bootstrap.js │ │ │ │ ├── bootstrap.js.map │ │ │ │ ├── bootstrap.min.js │ │ │ │ └── bootstrap.min.js.map │ │ │ ├── jquery-validation-unobtrusive │ │ │ ├── LICENSE.txt │ │ │ ├── jquery.validate.unobtrusive.js │ │ │ └── jquery.validate.unobtrusive.min.js │ │ │ ├── jquery-validation │ │ │ ├── LICENSE.md │ │ │ └── dist │ │ │ │ ├── additional-methods.js │ │ │ │ ├── additional-methods.min.js │ │ │ │ ├── jquery.validate.js │ │ │ │ └── jquery.validate.min.js │ │ │ └── jquery │ │ │ ├── LICENSE.txt │ │ │ └── dist │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ └── jquery.min.map │ └── images │ │ ├── configureproject.png │ │ ├── createnewproject.png │ │ ├── createwebapp-vsmac.png │ │ ├── createwebapp.png │ │ ├── install-ssl-certificate.png │ │ ├── nameproject-vsmac.png │ │ ├── newproject-vsmac.png │ │ ├── newproject.png │ │ ├── open-vs-code.png │ │ ├── projectfiles-vs.png │ │ ├── projectfiles-vsmac.png │ │ ├── razor-page.png │ │ └── ssl-certificate.png ├── 2-Add a model │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ ├── Addamodel-VS.md │ ├── Addamodel-VSMac.md │ ├── Addamodel.md │ ├── RazorPagesMovie.sln │ ├── RazorPagesMovie │ │ ├── Data │ │ │ └── RazorPagesMovieContext.cs │ │ ├── Migrations │ │ │ ├── 20220204181504_Initial.Designer.cs │ │ │ ├── 20220204181504_Initial.cs │ │ │ └── RazorPagesMovieContextModelSnapshot.cs │ │ ├── Models │ │ │ └── Movie.cs │ │ ├── MvcMovie.db │ │ ├── Pages │ │ │ ├── Error.cshtml │ │ │ ├── Error.cshtml.cs │ │ │ ├── Index.cshtml │ │ │ ├── Index.cshtml.cs │ │ │ ├── Movies │ │ │ │ ├── Create.cshtml │ │ │ │ ├── Create.cshtml.cs │ │ │ │ ├── Delete.cshtml │ │ │ │ ├── Delete.cshtml.cs │ │ │ │ ├── Details.cshtml │ │ │ │ ├── Details.cshtml.cs │ │ │ │ ├── Edit.cshtml │ │ │ │ ├── Edit.cshtml.cs │ │ │ │ ├── Index.cshtml │ │ │ │ └── Index.cshtml.cs │ │ │ ├── Privacy.cshtml │ │ │ ├── Privacy.cshtml.cs │ │ │ ├── Shared │ │ │ │ ├── _Layout.cshtml │ │ │ │ ├── _Layout.cshtml.css │ │ │ │ └── _ValidationScriptsPartial.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ └── _ViewStart.cshtml │ │ ├── Program.cs │ │ ├── Properties │ │ │ ├── serviceDependencies.json │ │ │ └── serviceDependencies.local.json │ │ ├── RazorPagesMovie.csproj │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ ├── css │ │ │ └── site.css │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ └── site.js │ │ │ └── lib │ │ │ ├── bootstrap │ │ │ ├── LICENSE │ │ │ └── dist │ │ │ │ ├── css │ │ │ │ ├── bootstrap-grid.css │ │ │ │ ├── bootstrap-grid.css.map │ │ │ │ ├── bootstrap-grid.min.css │ │ │ │ ├── bootstrap-grid.min.css.map │ │ │ │ ├── bootstrap-grid.rtl.css │ │ │ │ ├── bootstrap-grid.rtl.css.map │ │ │ │ ├── bootstrap-grid.rtl.min.css │ │ │ │ ├── bootstrap-grid.rtl.min.css.map │ │ │ │ ├── bootstrap-reboot.css │ │ │ │ ├── bootstrap-reboot.css.map │ │ │ │ ├── bootstrap-reboot.min.css │ │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ │ ├── bootstrap-reboot.rtl.css │ │ │ │ ├── bootstrap-reboot.rtl.css.map │ │ │ │ ├── bootstrap-reboot.rtl.min.css │ │ │ │ ├── bootstrap-reboot.rtl.min.css.map │ │ │ │ ├── bootstrap-utilities.css │ │ │ │ ├── bootstrap-utilities.css.map │ │ │ │ ├── bootstrap-utilities.min.css │ │ │ │ ├── bootstrap-utilities.min.css.map │ │ │ │ ├── bootstrap-utilities.rtl.css │ │ │ │ ├── bootstrap-utilities.rtl.css.map │ │ │ │ ├── bootstrap-utilities.rtl.min.css │ │ │ │ ├── bootstrap-utilities.rtl.min.css.map │ │ │ │ ├── bootstrap.css │ │ │ │ ├── bootstrap.css.map │ │ │ │ ├── bootstrap.min.css │ │ │ │ ├── bootstrap.min.css.map │ │ │ │ ├── bootstrap.rtl.css │ │ │ │ ├── bootstrap.rtl.css.map │ │ │ │ ├── bootstrap.rtl.min.css │ │ │ │ └── bootstrap.rtl.min.css.map │ │ │ │ └── js │ │ │ │ ├── bootstrap.bundle.js │ │ │ │ ├── bootstrap.bundle.js.map │ │ │ │ ├── bootstrap.bundle.min.js │ │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ │ ├── bootstrap.esm.js │ │ │ │ ├── bootstrap.esm.js.map │ │ │ │ ├── bootstrap.esm.min.js │ │ │ │ ├── bootstrap.esm.min.js.map │ │ │ │ ├── bootstrap.js │ │ │ │ ├── bootstrap.js.map │ │ │ │ ├── bootstrap.min.js │ │ │ │ └── bootstrap.min.js.map │ │ │ ├── jquery-validation-unobtrusive │ │ │ ├── LICENSE.txt │ │ │ ├── jquery.validate.unobtrusive.js │ │ │ └── jquery.validate.unobtrusive.min.js │ │ │ ├── jquery-validation │ │ │ ├── LICENSE.md │ │ │ └── dist │ │ │ │ ├── additional-methods.js │ │ │ │ ├── additional-methods.min.js │ │ │ │ ├── jquery.validate.js │ │ │ │ └── jquery.validate.min.js │ │ │ └── jquery │ │ │ ├── LICENSE.txt │ │ │ └── dist │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ └── jquery.min.map │ └── images │ │ ├── Models.PNG │ │ ├── Models.png │ │ ├── add-package-menu-vsmac.png │ │ ├── add-package-vsmac.png │ │ ├── add_razor_VS.png │ │ ├── add_scaffold_VS.png │ │ ├── addclass-vsmac.png │ │ ├── createnew.PNG │ │ ├── moviespage.PNG │ │ ├── newentry.PNG │ │ ├── pmc_VS.png │ │ └── scaffold_dialog_VS.png ├── 3-Update Pages │ ├── RazorPagesMovie │ │ ├── Data │ │ │ └── RazorPagesMovieContext.cs │ │ ├── Migrations │ │ │ ├── 20230411061819_Initial.Designer.cs │ │ │ ├── 20230411061819_Initial.cs │ │ │ └── RazorPagesMovieContextModelSnapshot.cs │ │ ├── Models │ │ │ └── Movie.cs │ │ ├── MvcMovie.db │ │ ├── Pages │ │ │ ├── Error.cshtml │ │ │ ├── Error.cshtml.cs │ │ │ ├── Index.cshtml │ │ │ ├── Index.cshtml.cs │ │ │ ├── Movies │ │ │ │ ├── Create.cshtml │ │ │ │ ├── Create.cshtml.cs │ │ │ │ ├── Delete.cshtml │ │ │ │ ├── Delete.cshtml.cs │ │ │ │ ├── Details.cshtml │ │ │ │ ├── Details.cshtml.cs │ │ │ │ ├── Edit.cshtml │ │ │ │ ├── Edit.cshtml.cs │ │ │ │ ├── Index.cshtml │ │ │ │ └── Index.cshtml.cs │ │ │ ├── Privacy.cshtml │ │ │ ├── Privacy.cshtml.cs │ │ │ ├── Shared │ │ │ │ ├── _Layout.cshtml │ │ │ │ ├── _Layout.cshtml.css │ │ │ │ └── _ValidationScriptsPartial.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ └── _ViewStart.cshtml │ │ ├── Program.cs │ │ ├── Properties │ │ │ ├── serviceDependencies.json │ │ │ └── serviceDependencies.local.json │ │ ├── RazorPagesMovie.csproj │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ ├── css │ │ │ └── site.css │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ └── site.js │ │ │ └── lib │ │ │ ├── bootstrap │ │ │ ├── LICENSE │ │ │ └── dist │ │ │ │ ├── css │ │ │ │ ├── bootstrap-grid.css │ │ │ │ ├── bootstrap-grid.css.map │ │ │ │ ├── bootstrap-grid.min.css │ │ │ │ ├── bootstrap-grid.min.css.map │ │ │ │ ├── bootstrap-grid.rtl.css │ │ │ │ ├── bootstrap-grid.rtl.css.map │ │ │ │ ├── bootstrap-grid.rtl.min.css │ │ │ │ ├── bootstrap-grid.rtl.min.css.map │ │ │ │ ├── bootstrap-reboot.css │ │ │ │ ├── bootstrap-reboot.css.map │ │ │ │ ├── bootstrap-reboot.min.css │ │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ │ ├── bootstrap-reboot.rtl.css │ │ │ │ ├── bootstrap-reboot.rtl.css.map │ │ │ │ ├── bootstrap-reboot.rtl.min.css │ │ │ │ ├── bootstrap-reboot.rtl.min.css.map │ │ │ │ ├── bootstrap-utilities.css │ │ │ │ ├── bootstrap-utilities.css.map │ │ │ │ ├── bootstrap-utilities.min.css │ │ │ │ ├── bootstrap-utilities.min.css.map │ │ │ │ ├── bootstrap-utilities.rtl.css │ │ │ │ ├── bootstrap-utilities.rtl.css.map │ │ │ │ ├── bootstrap-utilities.rtl.min.css │ │ │ │ ├── bootstrap-utilities.rtl.min.css.map │ │ │ │ ├── bootstrap.css │ │ │ │ ├── bootstrap.css.map │ │ │ │ ├── bootstrap.min.css │ │ │ │ ├── bootstrap.min.css.map │ │ │ │ ├── bootstrap.rtl.css │ │ │ │ ├── bootstrap.rtl.css.map │ │ │ │ ├── bootstrap.rtl.min.css │ │ │ │ └── bootstrap.rtl.min.css.map │ │ │ │ └── js │ │ │ │ ├── bootstrap.bundle.js │ │ │ │ ├── bootstrap.bundle.js.map │ │ │ │ ├── bootstrap.bundle.min.js │ │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ │ ├── bootstrap.esm.js │ │ │ │ ├── bootstrap.esm.js.map │ │ │ │ ├── bootstrap.esm.min.js │ │ │ │ ├── bootstrap.esm.min.js.map │ │ │ │ ├── bootstrap.js │ │ │ │ ├── bootstrap.js.map │ │ │ │ ├── bootstrap.min.js │ │ │ │ └── bootstrap.min.js.map │ │ │ ├── jquery-validation-unobtrusive │ │ │ ├── LICENSE.txt │ │ │ ├── jquery.validate.unobtrusive.js │ │ │ └── jquery.validate.unobtrusive.min.js │ │ │ ├── jquery-validation │ │ │ ├── LICENSE.md │ │ │ └── dist │ │ │ │ ├── additional-methods.js │ │ │ │ ├── additional-methods.min.js │ │ │ │ ├── jquery.validate.js │ │ │ │ └── jquery.validate.min.js │ │ │ └── jquery │ │ │ ├── LICENSE.txt │ │ │ └── dist │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ └── jquery.min.map │ ├── images │ │ ├── CurrentPage.PNG │ │ ├── NewPage.PNG │ │ ├── refactor_VS.png │ │ ├── refactor_VSMac.png │ │ ├── using_annotations_VS.png │ │ └── using_annotations_VSMac.png │ ├── update-VS.md │ ├── update-VSMac.md │ └── update.md └── 4-Add Search │ ├── .vscode │ ├── launch.json │ └── tasks.json │ ├── RazorPagesMovie │ ├── Data │ │ └── RazorPagesMovieContext.cs │ ├── Migrations │ │ ├── 20230411061819_Initial.Designer.cs │ │ ├── 20230411061819_Initial.cs │ │ └── RazorPagesMovieContextModelSnapshot.cs │ ├── Models │ │ └── Movie.cs │ ├── MvcMovie.db │ ├── Pages │ │ ├── Error.cshtml │ │ ├── Error.cshtml.cs │ │ ├── Index.cshtml │ │ ├── Index.cshtml.cs │ │ ├── Movies │ │ │ ├── Create.cshtml │ │ │ ├── Create.cshtml.cs │ │ │ ├── Delete.cshtml │ │ │ ├── Delete.cshtml.cs │ │ │ ├── Details.cshtml │ │ │ ├── Details.cshtml.cs │ │ │ ├── Edit.cshtml │ │ │ ├── Edit.cshtml.cs │ │ │ ├── Index.cshtml │ │ │ └── Index.cshtml.cs │ │ ├── Privacy.cshtml │ │ ├── Privacy.cshtml.cs │ │ ├── Shared │ │ │ ├── _Layout.cshtml │ │ │ ├── _Layout.cshtml.css │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── _ViewImports.cshtml │ │ └── _ViewStart.cshtml │ ├── Program.cs │ ├── Properties │ │ ├── serviceDependencies.json │ │ └── serviceDependencies.local.json │ ├── RazorPagesMovie.csproj │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ ├── css │ │ └── site.css │ │ ├── favicon.ico │ │ ├── js │ │ └── site.js │ │ └── lib │ │ ├── bootstrap │ │ ├── LICENSE │ │ └── dist │ │ │ ├── css │ │ │ ├── bootstrap-grid.css │ │ │ ├── bootstrap-grid.css.map │ │ │ ├── bootstrap-grid.min.css │ │ │ ├── bootstrap-grid.min.css.map │ │ │ ├── bootstrap-grid.rtl.css │ │ │ ├── bootstrap-grid.rtl.css.map │ │ │ ├── bootstrap-grid.rtl.min.css │ │ │ ├── bootstrap-grid.rtl.min.css.map │ │ │ ├── bootstrap-reboot.css │ │ │ ├── bootstrap-reboot.css.map │ │ │ ├── bootstrap-reboot.min.css │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ ├── bootstrap-reboot.rtl.css │ │ │ ├── bootstrap-reboot.rtl.css.map │ │ │ ├── bootstrap-reboot.rtl.min.css │ │ │ ├── bootstrap-reboot.rtl.min.css.map │ │ │ ├── bootstrap-utilities.css │ │ │ ├── bootstrap-utilities.css.map │ │ │ ├── bootstrap-utilities.min.css │ │ │ ├── bootstrap-utilities.min.css.map │ │ │ ├── bootstrap-utilities.rtl.css │ │ │ ├── bootstrap-utilities.rtl.css.map │ │ │ ├── bootstrap-utilities.rtl.min.css │ │ │ ├── bootstrap-utilities.rtl.min.css.map │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ ├── bootstrap.min.css │ │ │ ├── bootstrap.min.css.map │ │ │ ├── bootstrap.rtl.css │ │ │ ├── bootstrap.rtl.css.map │ │ │ ├── bootstrap.rtl.min.css │ │ │ └── bootstrap.rtl.min.css.map │ │ │ └── js │ │ │ ├── bootstrap.bundle.js │ │ │ ├── bootstrap.bundle.js.map │ │ │ ├── bootstrap.bundle.min.js │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ ├── bootstrap.esm.js │ │ │ ├── bootstrap.esm.js.map │ │ │ ├── bootstrap.esm.min.js │ │ │ ├── bootstrap.esm.min.js.map │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.js.map │ │ │ ├── bootstrap.min.js │ │ │ └── bootstrap.min.js.map │ │ ├── jquery-validation-unobtrusive │ │ ├── LICENSE.txt │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ │ ├── jquery-validation │ │ ├── LICENSE.md │ │ └── dist │ │ │ ├── additional-methods.js │ │ │ ├── additional-methods.min.js │ │ │ ├── jquery.validate.js │ │ │ └── jquery.validate.min.js │ │ └── jquery │ │ ├── LICENSE.txt │ │ └── dist │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ └── jquery.min.map │ ├── SearchPage-VS.md │ ├── SearchPage-VSMac.md │ ├── SearchPage.md │ └── images │ ├── genre.PNG │ ├── searchString.PNG │ └── searchform.PNG └── deck └── ASP.NETCore_Beginners.pptx /.github/workflows/build-validation.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | pull_request: 6 | branches: [ main ] 7 | paths: 8 | - '**.cs' 9 | - '**.csproj' 10 | - '**.cshtml' 11 | - '**.css' 12 | 13 | env: 14 | DOTNET_VERSION: '7.0.x' # The .NET SDK version to use 15 | 16 | jobs: 17 | build: 18 | 19 | name: Build All Projects 20 | runs-on: ubuntu-latest 21 | strategy: 22 | matrix: 23 | project: 24 | - Tutorial/1-Create a Razor Page 25 | - Tutorial/2-Add a model 26 | - Tutorial/3-Update Pages 27 | - Tutorial/4-Add Search 28 | - Final_Project 29 | 30 | steps: 31 | - uses: actions/checkout@v2 32 | - name: Setup .NET 33 | uses: actions/setup-dotnet@v2 34 | with: 35 | dotnet-version: ${{ env.DOTNET_VERSION }} 36 | 37 | - name: Build Step - ${{ matrix.project }} 38 | run: dotnet build "${{ matrix.project }}/RazorPagesMovie/RazorPagesMovie.csproj" 39 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32112.339 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RazorPagesMovie", "RazorPagesMovie\RazorPagesMovie.csproj", "{8D5781DC-DC5E-4FC4-8494-7831913C724E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {859A476B-56DC-4874-A8CD-170D89A81002} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Data/RazorPagesMovieContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using RazorPagesMovie.Models; 7 | 8 | namespace RazorPagesMovie.Data 9 | { 10 | public class RazorPagesMovieContext : DbContext 11 | { 12 | public RazorPagesMovieContext (DbContextOptions options) 13 | : base(options) 14 | { 15 | } 16 | 17 | public DbSet Movie { get; set; } = default!; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Migrations/20230411061819_Initial.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 7 | using RazorPagesMovie.Data; 8 | 9 | #nullable disable 10 | 11 | namespace RazorPagesMovie.Migrations 12 | { 13 | [DbContext(typeof(RazorPagesMovieContext))] 14 | [Migration("20230411061819_Initial")] 15 | partial class Initial 16 | { 17 | /// 18 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 19 | { 20 | #pragma warning disable 612, 618 21 | modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); 22 | 23 | modelBuilder.Entity("RazorPagesMovie.Models.Movie", b => 24 | { 25 | b.Property("ID") 26 | .ValueGeneratedOnAdd() 27 | .HasColumnType("INTEGER"); 28 | 29 | b.Property("Genre") 30 | .HasColumnType("TEXT"); 31 | 32 | b.Property("Price") 33 | .HasColumnType("TEXT"); 34 | 35 | b.Property("ReleaseDate") 36 | .HasColumnType("TEXT"); 37 | 38 | b.Property("Title") 39 | .HasColumnType("TEXT"); 40 | 41 | b.HasKey("ID"); 42 | 43 | b.ToTable("Movie"); 44 | }); 45 | #pragma warning restore 612, 618 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Migrations/20230411061819_Initial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | #nullable disable 5 | 6 | namespace RazorPagesMovie.Migrations 7 | { 8 | /// 9 | public partial class Initial : Migration 10 | { 11 | /// 12 | protected override void Up(MigrationBuilder migrationBuilder) 13 | { 14 | migrationBuilder.CreateTable( 15 | name: "Movie", 16 | columns: table => new 17 | { 18 | ID = table.Column(type: "INTEGER", nullable: false) 19 | .Annotation("Sqlite:Autoincrement", true), 20 | Title = table.Column(type: "TEXT", nullable: true), 21 | ReleaseDate = table.Column(type: "TEXT", nullable: false), 22 | Genre = table.Column(type: "TEXT", nullable: true), 23 | Price = table.Column(type: "TEXT", nullable: false) 24 | }, 25 | constraints: table => 26 | { 27 | table.PrimaryKey("PK_Movie", x => x.ID); 28 | }); 29 | } 30 | 31 | /// 32 | protected override void Down(MigrationBuilder migrationBuilder) 33 | { 34 | migrationBuilder.DropTable( 35 | name: "Movie"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Migrations/RazorPagesMovieContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 6 | using RazorPagesMovie.Data; 7 | 8 | #nullable disable 9 | 10 | namespace RazorPagesMovie.Migrations 11 | { 12 | [DbContext(typeof(RazorPagesMovieContext))] 13 | partial class RazorPagesMovieContextModelSnapshot : ModelSnapshot 14 | { 15 | protected override void BuildModel(ModelBuilder modelBuilder) 16 | { 17 | #pragma warning disable 612, 618 18 | modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); 19 | 20 | modelBuilder.Entity("RazorPagesMovie.Models.Movie", b => 21 | { 22 | b.Property("ID") 23 | .ValueGeneratedOnAdd() 24 | .HasColumnType("INTEGER"); 25 | 26 | b.Property("Genre") 27 | .HasColumnType("TEXT"); 28 | 29 | b.Property("Price") 30 | .HasColumnType("TEXT"); 31 | 32 | b.Property("ReleaseDate") 33 | .HasColumnType("TEXT"); 34 | 35 | b.Property("Title") 36 | .HasColumnType("TEXT"); 37 | 38 | b.HasKey("ID"); 39 | 40 | b.ToTable("Movie"); 41 | }); 42 | #pragma warning restore 612, 618 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Models/Movie.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Metadata.Internal; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | namespace RazorPagesMovie.Models; 6 | 7 | public class Movie 8 | { 9 | public int ID { get; set; } 10 | public string? Title { get; set; } 11 | 12 | [Display(Name = "Release Date")] 13 | [DataType(DataType.Date)] 14 | public DateTime ReleaseDate { get; set; } 15 | public string? Genre { get; set; } 16 | 17 | [Column(TypeName = "decimal(18, 2)")] 18 | public decimal Price { get; set; } 19 | } -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/MvcMovie.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Final_Project/RazorPagesMovie/MvcMovie.db -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace RazorPagesMovie.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 | } -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model IndexModel 3 | @{ 4 | ViewData["Title"] = "Home page"; 5 | } 6 | 7 |
8 |

Welcome

9 |

Learn about building Web apps with ASP.NET Core.

10 |
11 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages 5 | { 6 | public class IndexModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public IndexModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Create.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.CreateModel 3 | 4 | @{ 5 | ViewData["Title"] = "Create"; 6 | } 7 | 8 |

Create

9 | 10 |

Movie

11 |
12 |
13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 |
37 | 38 |
39 |
40 |
41 |
42 | 43 |
44 | Back to List 45 |
46 | 47 | @section Scripts { 48 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 49 | } 50 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Create.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class CreateModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public CreateModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public IActionResult OnGet() 23 | { 24 | return Page(); 25 | } 26 | 27 | [BindProperty] 28 | public Movie Movie { get; set; } = default!; 29 | 30 | 31 | // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD 32 | public async Task OnPostAsync() 33 | { 34 | if (!ModelState.IsValid || _context.Movie == null || Movie == null) 35 | { 36 | return Page(); 37 | } 38 | 39 | _context.Movie.Add(Movie); 40 | await _context.SaveChangesAsync(); 41 | 42 | return RedirectToPage("./Index"); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.DeleteModel 3 | 4 | @{ 5 | ViewData["Title"] = "Delete"; 6 | } 7 | 8 |

Delete

9 | 10 |

Are you sure you want to delete this?

11 |
12 |

Movie

13 |
14 |
15 |
16 | @Html.DisplayNameFor(model => model.Movie.Title) 17 |
18 |
19 | @Html.DisplayFor(model => model.Movie.Title) 20 |
21 |
22 | @Html.DisplayNameFor(model => model.Movie.ReleaseDate) 23 |
24 |
25 | @Html.DisplayFor(model => model.Movie.ReleaseDate) 26 |
27 |
28 | @Html.DisplayNameFor(model => model.Movie.Genre) 29 |
30 |
31 | @Html.DisplayFor(model => model.Movie.Genre) 32 |
33 |
34 | @Html.DisplayNameFor(model => model.Movie.Price) 35 |
36 |
37 | @Html.DisplayFor(model => model.Movie.Price) 38 |
39 |
40 | 41 |
42 | 43 | | 44 | Back to List 45 |
46 |
47 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Delete.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class DeleteModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public DeleteModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | [BindProperty] 23 | public Movie Movie { get; set; } = default!; 24 | 25 | public async Task OnGetAsync(int? id) 26 | { 27 | if (id == null || _context.Movie == null) 28 | { 29 | return NotFound(); 30 | } 31 | 32 | var movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 33 | 34 | if (movie == null) 35 | { 36 | return NotFound(); 37 | } 38 | else 39 | { 40 | Movie = movie; 41 | } 42 | return Page(); 43 | } 44 | 45 | public async Task OnPostAsync(int? id) 46 | { 47 | if (id == null || _context.Movie == null) 48 | { 49 | return NotFound(); 50 | } 51 | var movie = await _context.Movie.FindAsync(id); 52 | 53 | if (movie != null) 54 | { 55 | Movie = movie; 56 | _context.Movie.Remove(Movie); 57 | await _context.SaveChangesAsync(); 58 | } 59 | 60 | return RedirectToPage("./Index"); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Details.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.DetailsModel 3 | 4 | @{ 5 | ViewData["Title"] = "Details"; 6 | } 7 | 8 |

Details

9 | 10 |
11 |

Movie

12 |
13 |
14 |
15 | @Html.DisplayNameFor(model => model.Movie.Title) 16 |
17 |
18 | @Html.DisplayFor(model => model.Movie.Title) 19 |
20 |
21 | @Html.DisplayNameFor(model => model.Movie.ReleaseDate) 22 |
23 |
24 | @Html.DisplayFor(model => model.Movie.ReleaseDate) 25 |
26 |
27 | @Html.DisplayNameFor(model => model.Movie.Genre) 28 |
29 |
30 | @Html.DisplayFor(model => model.Movie.Genre) 31 |
32 |
33 | @Html.DisplayNameFor(model => model.Movie.Price) 34 |
35 |
36 | @Html.DisplayFor(model => model.Movie.Price) 37 |
38 |
39 |
40 |
41 | Edit | 42 | Back to List 43 |
44 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Details.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class DetailsModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public DetailsModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public Movie Movie { get; set; } = default!; 23 | 24 | public async Task OnGetAsync(int? id) 25 | { 26 | if (id == null || _context.Movie == null) 27 | { 28 | return NotFound(); 29 | } 30 | 31 | var movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 32 | if (movie == null) 33 | { 34 | return NotFound(); 35 | } 36 | else 37 | { 38 | Movie = movie; 39 | } 40 | return Page(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.EditModel 3 | 4 | @{ 5 | ViewData["Title"] = "Edit"; 6 | } 7 | 8 |

Edit

9 | 10 |

Movie

11 |
12 |
13 |
14 |
15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 |
27 |
28 | 29 | 30 | 31 |
32 |
33 | 34 | 35 | 36 |
37 |
38 | 39 |
40 |
41 |
42 |
43 | 44 |
45 | Back to List 46 |
47 | 48 | @section Scripts { 49 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 50 | } 51 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Edit.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using Microsoft.EntityFrameworkCore; 9 | using RazorPagesMovie.Data; 10 | using RazorPagesMovie.Models; 11 | 12 | namespace RazorPagesMovie.Pages.Movies 13 | { 14 | public class EditModel : PageModel 15 | { 16 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 17 | 18 | public EditModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | [BindProperty] 24 | public Movie Movie { get; set; } = default!; 25 | 26 | public async Task OnGetAsync(int? id) 27 | { 28 | if (id == null || _context.Movie == null) 29 | { 30 | return NotFound(); 31 | } 32 | 33 | var movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 34 | if (movie == null) 35 | { 36 | return NotFound(); 37 | } 38 | Movie = movie; 39 | return Page(); 40 | } 41 | 42 | // To protect from overposting attacks, enable the specific properties you want to bind to. 43 | // For more details, see https://aka.ms/RazorPagesCRUD. 44 | public async Task OnPostAsync() 45 | { 46 | if (!ModelState.IsValid) 47 | { 48 | return Page(); 49 | } 50 | 51 | _context.Attach(Movie).State = EntityState.Modified; 52 | 53 | try 54 | { 55 | await _context.SaveChangesAsync(); 56 | } 57 | catch (DbUpdateConcurrencyException) 58 | { 59 | if (!MovieExists(Movie.ID)) 60 | { 61 | return NotFound(); 62 | } 63 | else 64 | { 65 | throw; 66 | } 67 | } 68 | 69 | return RedirectToPage("./Index"); 70 | } 71 | 72 | private bool MovieExists(int id) 73 | { 74 | return (_context.Movie?.Any(e => e.ID == id)).GetValueOrDefault(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.IndexModel 3 | 4 | @{ 5 | ViewData["Title"] = "Index"; 6 | } 7 | 8 |

Index

9 | 10 |

11 | Create New 12 |

13 |
14 |

15 | 18 | 19 | Movie Title: 20 | 21 |

22 |
23 | 24 | 25 | 26 | 29 | 32 | 35 | 38 | 39 | 40 | 41 | 42 | @foreach (var item in Model.Movie) { 43 | 44 | 47 | 50 | 53 | 56 | 61 | 62 | } 63 | 64 |
27 | @Html.DisplayNameFor(model => model.Movie[0].Title) 28 | 30 | @Html.DisplayNameFor(model => model.Movie[0].ReleaseDate) 31 | 33 | @Html.DisplayNameFor(model => model.Movie[0].Genre) 34 | 36 | @Html.DisplayNameFor(model => model.Movie[0].Price) 37 |
45 | @Html.DisplayFor(modelItem => item.Title) 46 | 48 | @Html.DisplayFor(modelItem => item.ReleaseDate) 49 | 51 | @Html.DisplayFor(modelItem => item.Genre) 52 | 54 | @Html.DisplayFor(modelItem => item.Price) 55 | 57 | Edit | 58 | Details | 59 | Delete 60 |
65 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Movies/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using Microsoft.EntityFrameworkCore; 9 | using RazorPagesMovie.Data; 10 | using RazorPagesMovie.Models; 11 | 12 | namespace RazorPagesMovie.Pages.Movies 13 | { 14 | public class IndexModel : PageModel 15 | { 16 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 17 | 18 | public IndexModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | public IList Movie { get;set; } = default!; 24 | public SelectList Genres; 25 | public string MovieGenre { get; set; } 26 | 27 | public async Task OnGetAsync(string movieGenre, string searchString) 28 | { 29 | IQueryable genreQuery = from m in _context.Movie 30 | orderby m.Genre 31 | select m.Genre; 32 | 33 | var movies = from m in _context.Movie 34 | select m; 35 | 36 | if (!String.IsNullOrEmpty(searchString)) 37 | { 38 | movies = movies.Where(s => s.Title.Contains(searchString)); 39 | } 40 | 41 | if (!String.IsNullOrEmpty(movieGenre)) 42 | { 43 | movies = movies.Where(x => x.Genre == movieGenre); 44 | } 45 | Genres = new SelectList(await genreQuery.Distinct().ToListAsync()); 46 | Movie = await movies.ToListAsync(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model PrivacyModel 3 | @{ 4 | ViewData["Title"] = "Privacy Policy"; 5 | } 6 |

@ViewData["Title"]

7 | 8 |

Use this page to detail your site's privacy policy.

9 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Privacy.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages 5 | { 6 | public class PrivacyModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public PrivacyModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - RazorPagesMovie 7 | 8 | 9 | 10 | 11 | 12 |
13 | 32 |
33 |
34 |
35 | @RenderBody() 36 |
37 |
38 | 39 |
40 |
41 | © 2023 - RazorPagesMovie - Privacy 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | @await RenderSectionAsync("Scripts", required: false) 50 | 51 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Shared/_Layout.cshtml.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using RazorPagesMovie 2 | @namespace RazorPagesMovie.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using RazorPagesMovie.Data; 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | // Add services to the container. 7 | builder.Services.AddRazorPages(); 8 | builder.Services.AddDbContext(options => 9 | options.UseSqlite(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found."))); 10 | 11 | var app = builder.Build(); 12 | 13 | // Configure the HTTP request pipeline. 14 | if (!app.Environment.IsDevelopment()) 15 | { 16 | app.UseExceptionHandler("/Error"); 17 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 18 | app.UseHsts(); 19 | } 20 | 21 | app.UseHttpsRedirection(); 22 | app.UseStaticFiles(); 23 | 24 | app.UseRouting(); 25 | 26 | app.UseAuthorization(); 27 | 28 | app.MapRazorPages(); 29 | 30 | app.Run(); 31 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql", 5 | "connectionId": "ConnectionStrings:RazorPagesMovieContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql.local", 5 | "connectionId": "ConnectionStrings:RazorPagesMovieContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/RazorPagesMovie.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "RazorPagesMovieContext": "Data Source=MvcMovie.db" 11 | } 12 | } -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-size: 14px; 3 | } 4 | 5 | @media (min-width: 768px) { 6 | html { 7 | font-size: 16px; 8 | } 9 | } 10 | 11 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 12 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 13 | } 14 | 15 | html { 16 | position: relative; 17 | min-height: 100%; 18 | } 19 | 20 | body { 21 | margin-bottom: 60px; 22 | } -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Final_Project/RazorPagesMovie/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2021 Twitter, Inc. 4 | Copyright (c) 2011-2021 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) .NET Foundation and Contributors 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Final_Project/RazorPagesMovie/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright OpenJS Foundation and other contributors, https://openjsf.org/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 dotnet-presentations 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/RazorPagesMovie/bin/Debug/netcoreapp2.2/RazorPagesMovie.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/RazorPagesMovie", 16 | "stopAtEntry": false, 17 | "internalConsoleOptions": "openOnSessionStart", 18 | "launchBrowser": { 19 | "enabled": true, 20 | "args": "${auto-detect-url}", 21 | "windows": { 22 | "command": "cmd.exe", 23 | "args": "/C start ${auto-detect-url}" 24 | }, 25 | "osx": { 26 | "command": "open" 27 | }, 28 | "linux": { 29 | "command": "xdg-open" 30 | } 31 | }, 32 | "env": { 33 | "ASPNETCORE_ENVIRONMENT": "Development" 34 | }, 35 | "sourceFileMap": { 36 | "/Views": "${workspaceFolder}/Views" 37 | } 38 | }, 39 | { 40 | "name": ".NET Core Attach", 41 | "type": "coreclr", 42 | "request": "attach", 43 | "processId": "${command:pickProcess}" 44 | } 45 | ,] 46 | } -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/RazorPagesMovie/RazorPagesMovie.csproj" 11 | ], 12 | "problemMatcher": "$msCompile" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32112.339 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RazorPagesMovie", "RazorPagesMovie\RazorPagesMovie.csproj", "{8D5781DC-DC5E-4FC4-8494-7831913C724E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {859A476B-56DC-4874-A8CD-170D89A81002} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.AspNetCore.Mvc.RazorPages; 4 | 5 | namespace RazorPagesMovie.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 | 28 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model IndexModel 3 | @{ 4 | ViewData["Title"] = "Home page"; 5 | } 6 | 7 |
8 |

Welcome

9 |

Learn about building Web apps with ASP.NET Core.

10 |
11 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages; 5 | 6 | public class IndexModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public IndexModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model PrivacyModel 3 | @{ 4 | ViewData["Title"] = "Privacy Policy"; 5 | } 6 |

@ViewData["Title"]

7 | 8 |

Use this page to detail your site's privacy policy.

9 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/Privacy.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages; 5 | 6 | public class PrivacyModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public PrivacyModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - RazorPagesMovie 7 | 8 | 9 | 10 | 11 | 12 |
13 | 32 |
33 |
34 |
35 | @RenderBody() 36 |
37 |
38 | 39 |
40 |
41 | © 2023 - RazorPagesMovie - Privacy 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | @await RenderSectionAsync("Scripts", required: false) 50 | 51 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/Shared/_Layout.cshtml.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using RazorPagesMovie 2 | @namespace RazorPagesMovie.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | 3 | // Add services to the container. 4 | builder.Services.AddRazorPages(); 5 | 6 | var app = builder.Build(); 7 | 8 | // Configure the HTTP request pipeline. 9 | if (!app.Environment.IsDevelopment()) 10 | { 11 | app.UseExceptionHandler("/Error"); 12 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 13 | app.UseHsts(); 14 | } 15 | 16 | app.UseHttpsRedirection(); 17 | app.UseStaticFiles(); 18 | 19 | app.UseRouting(); 20 | 21 | app.UseAuthorization(); 22 | 23 | app.MapRazorPages(); 24 | 25 | app.Run(); 26 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/RazorPagesMovie.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-size: 14px; 3 | } 4 | 5 | @media (min-width: 768px) { 6 | html { 7 | font-size: 16px; 8 | } 9 | } 10 | 11 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 12 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 13 | } 14 | 15 | html { 16 | position: relative; 17 | min-height: 100%; 18 | } 19 | 20 | body { 21 | margin-bottom: 60px; 22 | } -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/RazorPagesMovie/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2021 Twitter, Inc. 4 | Copyright (c) 2011-2021 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) .NET Foundation and Contributors 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/RazorPagesMovie/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright OpenJS Foundation and other contributors, https://openjsf.org/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/configureproject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/configureproject.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/createnewproject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/createnewproject.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/createwebapp-vsmac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/createwebapp-vsmac.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/createwebapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/createwebapp.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/install-ssl-certificate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/install-ssl-certificate.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/nameproject-vsmac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/nameproject-vsmac.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/newproject-vsmac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/newproject-vsmac.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/newproject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/newproject.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/open-vs-code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/open-vs-code.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/projectfiles-vs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/projectfiles-vs.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/projectfiles-vsmac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/projectfiles-vsmac.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/razor-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/razor-page.png -------------------------------------------------------------------------------- /Tutorial/1-Create a Razor Page/images/ssl-certificate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/1-Create a Razor Page/images/ssl-certificate.png -------------------------------------------------------------------------------- /Tutorial/2-Add a model/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/RazorPagesMovie/bin/Debug/netcoreapp2.2/RazorPagesMovie.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/RazorPagesMovie", 16 | "stopAtEntry": false, 17 | "internalConsoleOptions": "openOnSessionStart", 18 | "launchBrowser": { 19 | "enabled": true, 20 | "args": "${auto-detect-url}", 21 | "windows": { 22 | "command": "cmd.exe", 23 | "args": "/C start ${auto-detect-url}" 24 | }, 25 | "osx": { 26 | "command": "open" 27 | }, 28 | "linux": { 29 | "command": "xdg-open" 30 | } 31 | }, 32 | "env": { 33 | "ASPNETCORE_ENVIRONMENT": "Development" 34 | }, 35 | "sourceFileMap": { 36 | "/Views": "${workspaceFolder}/Views" 37 | } 38 | }, 39 | { 40 | "name": ".NET Core Attach", 41 | "type": "coreclr", 42 | "request": "attach", 43 | "processId": "${command:pickProcess}" 44 | } 45 | ,] 46 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/RazorPagesMovie/RazorPagesMovie.csproj" 11 | ], 12 | "problemMatcher": "$msCompile" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32112.339 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RazorPagesMovie", "RazorPagesMovie\RazorPagesMovie.csproj", "{8D5781DC-DC5E-4FC4-8494-7831913C724E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8D5781DC-DC5E-4FC4-8494-7831913C724E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {859A476B-56DC-4874-A8CD-170D89A81002} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Data/RazorPagesMovieContext.cs: -------------------------------------------------------------------------------- 1 | #nullable disable 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.EntityFrameworkCore; 7 | using RazorPagesMovie.Models; 8 | 9 | namespace RazorPagesMovie.Data 10 | { 11 | public class RazorPagesMovieContext : DbContext 12 | { 13 | public RazorPagesMovieContext (DbContextOptions options) 14 | : base(options) 15 | { 16 | } 17 | 18 | public DbSet Movie { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Migrations/20220204181504_Initial.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 7 | using RazorPagesMovie.Data; 8 | 9 | #nullable disable 10 | 11 | namespace RazorPagesMovie.Migrations 12 | { 13 | [DbContext(typeof(RazorPagesMovieContext))] 14 | [Migration("20220204181504_Initial")] 15 | partial class Initial 16 | { 17 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 18 | { 19 | #pragma warning disable 612, 618 20 | modelBuilder.HasAnnotation("ProductVersion", "6.0.1"); 21 | 22 | modelBuilder.Entity("RazorPagesMovie.Models.Movie", b => 23 | { 24 | b.Property("ID") 25 | .ValueGeneratedOnAdd() 26 | .HasColumnType("INTEGER"); 27 | 28 | b.Property("Genre") 29 | .HasColumnType("TEXT"); 30 | 31 | b.Property("Price") 32 | .HasColumnType("TEXT"); 33 | 34 | b.Property("ReleaseDate") 35 | .HasColumnType("TEXT"); 36 | 37 | b.Property("Title") 38 | .HasColumnType("TEXT"); 39 | 40 | b.HasKey("ID"); 41 | 42 | b.ToTable("Movie"); 43 | }); 44 | #pragma warning restore 612, 618 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Migrations/20220204181504_Initial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | #nullable disable 5 | 6 | namespace RazorPagesMovie.Migrations 7 | { 8 | public partial class Initial : Migration 9 | { 10 | protected override void Up(MigrationBuilder migrationBuilder) 11 | { 12 | migrationBuilder.CreateTable( 13 | name: "Movie", 14 | columns: table => new 15 | { 16 | ID = table.Column(type: "INTEGER", nullable: false) 17 | .Annotation("Sqlite:Autoincrement", true), 18 | Title = table.Column(type: "TEXT", nullable: true), 19 | ReleaseDate = table.Column(type: "TEXT", nullable: false), 20 | Genre = table.Column(type: "TEXT", nullable: true), 21 | Price = table.Column(type: "TEXT", nullable: false) 22 | }, 23 | constraints: table => 24 | { 25 | table.PrimaryKey("PK_Movie", x => x.ID); 26 | }); 27 | } 28 | 29 | protected override void Down(MigrationBuilder migrationBuilder) 30 | { 31 | migrationBuilder.DropTable( 32 | name: "Movie"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Migrations/RazorPagesMovieContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 6 | using RazorPagesMovie.Data; 7 | 8 | #nullable disable 9 | 10 | namespace RazorPagesMovie.Migrations 11 | { 12 | [DbContext(typeof(RazorPagesMovieContext))] 13 | partial class RazorPagesMovieContextModelSnapshot : ModelSnapshot 14 | { 15 | protected override void BuildModel(ModelBuilder modelBuilder) 16 | { 17 | #pragma warning disable 612, 618 18 | modelBuilder.HasAnnotation("ProductVersion", "6.0.1"); 19 | 20 | modelBuilder.Entity("RazorPagesMovie.Models.Movie", b => 21 | { 22 | b.Property("ID") 23 | .ValueGeneratedOnAdd() 24 | .HasColumnType("INTEGER"); 25 | 26 | b.Property("Genre") 27 | .HasColumnType("TEXT"); 28 | 29 | b.Property("Price") 30 | .HasColumnType("TEXT"); 31 | 32 | b.Property("ReleaseDate") 33 | .HasColumnType("TEXT"); 34 | 35 | b.Property("Title") 36 | .HasColumnType("TEXT"); 37 | 38 | b.HasKey("ID"); 39 | 40 | b.ToTable("Movie"); 41 | }); 42 | #pragma warning restore 612, 618 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Models/Movie.cs: -------------------------------------------------------------------------------- 1 | namespace RazorPagesMovie.Models; 2 | 3 | public class Movie 4 | { 5 | public int ID { get; set; } 6 | public string? Title { get; set; } 7 | public DateTime ReleaseDate { get; set; } 8 | public string? Genre { get; set; } 9 | public decimal Price { get; set; } 10 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/MvcMovie.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/RazorPagesMovie/MvcMovie.db -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace RazorPagesMovie.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 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model IndexModel 3 | @{ 4 | ViewData["Title"] = "Home page"; 5 | } 6 | 7 |
8 |

Welcome

9 |

Learn about building Web apps with ASP.NET Core.

10 |
11 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages 5 | { 6 | public class IndexModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public IndexModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Create.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.CreateModel 3 | 4 | @{ 5 | ViewData["Title"] = "Create"; 6 | } 7 | 8 |

Create

9 | 10 |

Movie

11 |
12 |
13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 |
37 | 38 |
39 |
40 |
41 |
42 | 43 |
44 | Back to List 45 |
46 | 47 | @section Scripts { 48 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 49 | } 50 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Create.cshtml.cs: -------------------------------------------------------------------------------- 1 | #nullable disable 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Mvc.RazorPages; 8 | using Microsoft.AspNetCore.Mvc.Rendering; 9 | using RazorPagesMovie.Data; 10 | using RazorPagesMovie.Models; 11 | 12 | namespace RazorPagesMovie.Pages.Movies 13 | { 14 | public class CreateModel : PageModel 15 | { 16 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 17 | 18 | public CreateModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | public IActionResult OnGet() 24 | { 25 | return Page(); 26 | } 27 | 28 | [BindProperty] 29 | public Movie Movie { get; set; } 30 | 31 | // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD 32 | public async Task OnPostAsync() 33 | { 34 | if (!ModelState.IsValid) 35 | { 36 | return Page(); 37 | } 38 | 39 | _context.Movie.Add(Movie); 40 | await _context.SaveChangesAsync(); 41 | 42 | return RedirectToPage("./Index"); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.DeleteModel 3 | 4 | @{ 5 | ViewData["Title"] = "Delete"; 6 | } 7 | 8 |

Delete

9 | 10 |

Are you sure you want to delete this?

11 |
12 |

Movie

13 |
14 |
15 |
16 | @Html.DisplayNameFor(model => model.Movie.Title) 17 |
18 |
19 | @Html.DisplayFor(model => model.Movie.Title) 20 |
21 |
22 | @Html.DisplayNameFor(model => model.Movie.ReleaseDate) 23 |
24 |
25 | @Html.DisplayFor(model => model.Movie.ReleaseDate) 26 |
27 |
28 | @Html.DisplayNameFor(model => model.Movie.Genre) 29 |
30 |
31 | @Html.DisplayFor(model => model.Movie.Genre) 32 |
33 |
34 | @Html.DisplayNameFor(model => model.Movie.Price) 35 |
36 |
37 | @Html.DisplayFor(model => model.Movie.Price) 38 |
39 |
40 | 41 |
42 | 43 | | 44 | Back to List 45 |
46 |
47 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Delete.cshtml.cs: -------------------------------------------------------------------------------- 1 | #nullable disable 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Mvc.RazorPages; 8 | using Microsoft.EntityFrameworkCore; 9 | using RazorPagesMovie.Data; 10 | using RazorPagesMovie.Models; 11 | 12 | namespace RazorPagesMovie.Pages.Movies 13 | { 14 | public class DeleteModel : PageModel 15 | { 16 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 17 | 18 | public DeleteModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | [BindProperty] 24 | public Movie Movie { get; set; } 25 | 26 | public async Task OnGetAsync(int? id) 27 | { 28 | if (id == null) 29 | { 30 | return NotFound(); 31 | } 32 | 33 | Movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 34 | 35 | if (Movie == null) 36 | { 37 | return NotFound(); 38 | } 39 | return Page(); 40 | } 41 | 42 | public async Task OnPostAsync(int? id) 43 | { 44 | if (id == null) 45 | { 46 | return NotFound(); 47 | } 48 | 49 | Movie = await _context.Movie.FindAsync(id); 50 | 51 | if (Movie != null) 52 | { 53 | _context.Movie.Remove(Movie); 54 | await _context.SaveChangesAsync(); 55 | } 56 | 57 | return RedirectToPage("./Index"); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Details.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.DetailsModel 3 | 4 | @{ 5 | ViewData["Title"] = "Details"; 6 | } 7 | 8 |

Details

9 | 10 |
11 |

Movie

12 |
13 |
14 |
15 | @Html.DisplayNameFor(model => model.Movie.Title) 16 |
17 |
18 | @Html.DisplayFor(model => model.Movie.Title) 19 |
20 |
21 | @Html.DisplayNameFor(model => model.Movie.ReleaseDate) 22 |
23 |
24 | @Html.DisplayFor(model => model.Movie.ReleaseDate) 25 |
26 |
27 | @Html.DisplayNameFor(model => model.Movie.Genre) 28 |
29 |
30 | @Html.DisplayFor(model => model.Movie.Genre) 31 |
32 |
33 | @Html.DisplayNameFor(model => model.Movie.Price) 34 |
35 |
36 | @Html.DisplayFor(model => model.Movie.Price) 37 |
38 |
39 |
40 |
41 | Edit | 42 | Back to List 43 |
44 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Details.cshtml.cs: -------------------------------------------------------------------------------- 1 | #nullable disable 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Mvc.RazorPages; 8 | using Microsoft.EntityFrameworkCore; 9 | using RazorPagesMovie.Data; 10 | using RazorPagesMovie.Models; 11 | 12 | namespace RazorPagesMovie.Pages.Movies 13 | { 14 | public class DetailsModel : PageModel 15 | { 16 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 17 | 18 | public DetailsModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | public Movie Movie { get; set; } 24 | 25 | public async Task OnGetAsync(int? id) 26 | { 27 | if (id == null) 28 | { 29 | return NotFound(); 30 | } 31 | 32 | Movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 33 | 34 | if (Movie == null) 35 | { 36 | return NotFound(); 37 | } 38 | return Page(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.EditModel 3 | 4 | @{ 5 | ViewData["Title"] = "Edit"; 6 | } 7 | 8 |

Edit

9 | 10 |

Movie

11 |
12 |
13 |
14 |
15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 |
27 |
28 | 29 | 30 | 31 |
32 |
33 | 34 | 35 | 36 |
37 |
38 | 39 |
40 |
41 |
42 |
43 | 44 |
45 | Back to List 46 |
47 | 48 | @section Scripts { 49 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 50 | } 51 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Edit.cshtml.cs: -------------------------------------------------------------------------------- 1 | #nullable disable 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Mvc.RazorPages; 8 | using Microsoft.AspNetCore.Mvc.Rendering; 9 | using Microsoft.EntityFrameworkCore; 10 | using RazorPagesMovie.Data; 11 | using RazorPagesMovie.Models; 12 | 13 | namespace RazorPagesMovie.Pages.Movies 14 | { 15 | public class EditModel : PageModel 16 | { 17 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 18 | 19 | public EditModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 20 | { 21 | _context = context; 22 | } 23 | 24 | [BindProperty] 25 | public Movie Movie { get; set; } 26 | 27 | public async Task OnGetAsync(int? id) 28 | { 29 | if (id == null) 30 | { 31 | return NotFound(); 32 | } 33 | 34 | Movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 35 | 36 | if (Movie == null) 37 | { 38 | return NotFound(); 39 | } 40 | return Page(); 41 | } 42 | 43 | // To protect from overposting attacks, enable the specific properties you want to bind to. 44 | // For more details, see https://aka.ms/RazorPagesCRUD. 45 | public async Task OnPostAsync() 46 | { 47 | if (!ModelState.IsValid) 48 | { 49 | return Page(); 50 | } 51 | 52 | _context.Attach(Movie).State = EntityState.Modified; 53 | 54 | try 55 | { 56 | await _context.SaveChangesAsync(); 57 | } 58 | catch (DbUpdateConcurrencyException) 59 | { 60 | if (!MovieExists(Movie.ID)) 61 | { 62 | return NotFound(); 63 | } 64 | else 65 | { 66 | throw; 67 | } 68 | } 69 | 70 | return RedirectToPage("./Index"); 71 | } 72 | 73 | private bool MovieExists(int id) 74 | { 75 | return _context.Movie.Any(e => e.ID == id); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.IndexModel 3 | 4 | @{ 5 | ViewData["Title"] = "Index"; 6 | } 7 | 8 |

Index

9 | 10 |

11 | Create New 12 |

13 | 14 | 15 | 16 | 19 | 22 | 25 | 28 | 29 | 30 | 31 | 32 | @foreach (var item in Model.Movie) { 33 | 34 | 37 | 40 | 43 | 46 | 51 | 52 | } 53 | 54 |
17 | @Html.DisplayNameFor(model => model.Movie[0].Title) 18 | 20 | @Html.DisplayNameFor(model => model.Movie[0].ReleaseDate) 21 | 23 | @Html.DisplayNameFor(model => model.Movie[0].Genre) 24 | 26 | @Html.DisplayNameFor(model => model.Movie[0].Price) 27 |
35 | @Html.DisplayFor(modelItem => item.Title) 36 | 38 | @Html.DisplayFor(modelItem => item.ReleaseDate) 39 | 41 | @Html.DisplayFor(modelItem => item.Genre) 42 | 44 | @Html.DisplayFor(modelItem => item.Price) 45 | 47 | Edit | 48 | Details | 49 | Delete 50 |
55 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Movies/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | #nullable disable 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Mvc.RazorPages; 8 | using Microsoft.EntityFrameworkCore; 9 | using RazorPagesMovie.Data; 10 | using RazorPagesMovie.Models; 11 | 12 | namespace RazorPagesMovie.Pages.Movies 13 | { 14 | public class IndexModel : PageModel 15 | { 16 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 17 | 18 | public IndexModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | public IList Movie { get;set; } 24 | 25 | public async Task OnGetAsync() 26 | { 27 | Movie = await _context.Movie.ToListAsync(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model PrivacyModel 3 | @{ 4 | ViewData["Title"] = "Privacy Policy"; 5 | } 6 |

@ViewData["Title"]

7 | 8 |

Use this page to detail your site's privacy policy.

9 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Privacy.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages 5 | { 6 | public class PrivacyModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public PrivacyModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - RazorPagesMovie 7 | 8 | 9 | 10 | 11 | 12 |
13 | 32 |
33 |
34 |
35 | @RenderBody() 36 |
37 |
38 | 39 |
40 |
41 | © 2022 - RazorPagesMovie - Privacy 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | @await RenderSectionAsync("Scripts", required: false) 50 | 51 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Shared/_Layout.cshtml.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using RazorPagesMovie 2 | @namespace RazorPagesMovie.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using RazorPagesMovie.Data; 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | // Add services to the container. 7 | builder.Services.AddRazorPages(); 8 | 9 | var connectionString = builder.Configuration.GetConnectionString("RazorPagesMovieContext"); 10 | builder.Services.AddSqlite(connectionString); 11 | 12 | var app = builder.Build(); 13 | 14 | // Configure the HTTP request pipeline. 15 | if (!app.Environment.IsDevelopment()) 16 | { 17 | app.UseExceptionHandler("/Error"); 18 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 19 | app.UseHsts(); 20 | } 21 | 22 | app.UseHttpsRedirection(); 23 | app.UseStaticFiles(); 24 | 25 | app.UseRouting(); 26 | 27 | app.UseAuthorization(); 28 | 29 | app.MapRazorPages(); 30 | 31 | app.Run(); 32 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql", 5 | "connectionId": "ConnectionStrings:RazorPagesMovieContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql.local", 5 | "connectionId": "ConnectionStrings:RazorPagesMovieContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/RazorPagesMovie.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "RazorPagesMovieContext": "Data Source=MvcMovie.db" 11 | } 12 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-size: 14px; 3 | } 4 | 5 | @media (min-width: 768px) { 6 | html { 7 | font-size: 16px; 8 | } 9 | } 10 | 11 | html { 12 | position: relative; 13 | min-height: 100%; 14 | } 15 | 16 | body { 17 | margin-bottom: 60px; 18 | } -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/RazorPagesMovie/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2021 Twitter, Inc. 4 | Copyright (c) 2011-2021 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/RazorPagesMovie/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/Models.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/Models.PNG -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/Models.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/Models.png -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/add-package-menu-vsmac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/add-package-menu-vsmac.png -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/add-package-vsmac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/add-package-vsmac.png -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/add_razor_VS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/add_razor_VS.png -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/add_scaffold_VS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/add_scaffold_VS.png -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/addclass-vsmac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/addclass-vsmac.png -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/createnew.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/createnew.PNG -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/moviespage.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/moviespage.PNG -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/newentry.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/newentry.PNG -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/pmc_VS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/pmc_VS.png -------------------------------------------------------------------------------- /Tutorial/2-Add a model/images/scaffold_dialog_VS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/2-Add a model/images/scaffold_dialog_VS.png -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Data/RazorPagesMovieContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using RazorPagesMovie.Models; 7 | 8 | namespace RazorPagesMovie.Data 9 | { 10 | public class RazorPagesMovieContext : DbContext 11 | { 12 | public RazorPagesMovieContext (DbContextOptions options) 13 | : base(options) 14 | { 15 | } 16 | 17 | public DbSet Movie { get; set; } = default!; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Migrations/20230411061819_Initial.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 7 | using RazorPagesMovie.Data; 8 | 9 | #nullable disable 10 | 11 | namespace RazorPagesMovie.Migrations 12 | { 13 | [DbContext(typeof(RazorPagesMovieContext))] 14 | [Migration("20230411061819_Initial")] 15 | partial class Initial 16 | { 17 | /// 18 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 19 | { 20 | #pragma warning disable 612, 618 21 | modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); 22 | 23 | modelBuilder.Entity("RazorPagesMovie.Models.Movie", b => 24 | { 25 | b.Property("ID") 26 | .ValueGeneratedOnAdd() 27 | .HasColumnType("INTEGER"); 28 | 29 | b.Property("Genre") 30 | .HasColumnType("TEXT"); 31 | 32 | b.Property("Price") 33 | .HasColumnType("TEXT"); 34 | 35 | b.Property("ReleaseDate") 36 | .HasColumnType("TEXT"); 37 | 38 | b.Property("Title") 39 | .HasColumnType("TEXT"); 40 | 41 | b.HasKey("ID"); 42 | 43 | b.ToTable("Movie"); 44 | }); 45 | #pragma warning restore 612, 618 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Migrations/20230411061819_Initial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | #nullable disable 5 | 6 | namespace RazorPagesMovie.Migrations 7 | { 8 | /// 9 | public partial class Initial : Migration 10 | { 11 | /// 12 | protected override void Up(MigrationBuilder migrationBuilder) 13 | { 14 | migrationBuilder.CreateTable( 15 | name: "Movie", 16 | columns: table => new 17 | { 18 | ID = table.Column(type: "INTEGER", nullable: false) 19 | .Annotation("Sqlite:Autoincrement", true), 20 | Title = table.Column(type: "TEXT", nullable: true), 21 | ReleaseDate = table.Column(type: "TEXT", nullable: false), 22 | Genre = table.Column(type: "TEXT", nullable: true), 23 | Price = table.Column(type: "TEXT", nullable: false) 24 | }, 25 | constraints: table => 26 | { 27 | table.PrimaryKey("PK_Movie", x => x.ID); 28 | }); 29 | } 30 | 31 | /// 32 | protected override void Down(MigrationBuilder migrationBuilder) 33 | { 34 | migrationBuilder.DropTable( 35 | name: "Movie"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Migrations/RazorPagesMovieContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 6 | using RazorPagesMovie.Data; 7 | 8 | #nullable disable 9 | 10 | namespace RazorPagesMovie.Migrations 11 | { 12 | [DbContext(typeof(RazorPagesMovieContext))] 13 | partial class RazorPagesMovieContextModelSnapshot : ModelSnapshot 14 | { 15 | protected override void BuildModel(ModelBuilder modelBuilder) 16 | { 17 | #pragma warning disable 612, 618 18 | modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); 19 | 20 | modelBuilder.Entity("RazorPagesMovie.Models.Movie", b => 21 | { 22 | b.Property("ID") 23 | .ValueGeneratedOnAdd() 24 | .HasColumnType("INTEGER"); 25 | 26 | b.Property("Genre") 27 | .HasColumnType("TEXT"); 28 | 29 | b.Property("Price") 30 | .HasColumnType("TEXT"); 31 | 32 | b.Property("ReleaseDate") 33 | .HasColumnType("TEXT"); 34 | 35 | b.Property("Title") 36 | .HasColumnType("TEXT"); 37 | 38 | b.HasKey("ID"); 39 | 40 | b.ToTable("Movie"); 41 | }); 42 | #pragma warning restore 612, 618 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Models/Movie.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Metadata.Internal; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | namespace RazorPagesMovie.Models; 6 | 7 | public class Movie 8 | { 9 | public int ID { get; set; } 10 | public string? Title { get; set; } 11 | 12 | [Display(Name = "Release Date")] 13 | [DataType(DataType.Date)] 14 | public DateTime ReleaseDate { get; set; } 15 | public string? Genre { get; set; } 16 | 17 | [Column(TypeName = "decimal(18, 2)")] 18 | public decimal Price { get; set; } 19 | } -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/MvcMovie.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/3-Update Pages/RazorPagesMovie/MvcMovie.db -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace RazorPagesMovie.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 | } -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model IndexModel 3 | @{ 4 | ViewData["Title"] = "Home page"; 5 | } 6 | 7 |
8 |

Welcome

9 |

Learn about building Web apps with ASP.NET Core.

10 |
11 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages 5 | { 6 | public class IndexModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public IndexModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Create.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.CreateModel 3 | 4 | @{ 5 | ViewData["Title"] = "Create"; 6 | } 7 | 8 |

Create

9 | 10 |

Movie

11 |
12 |
13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 |
37 | 38 |
39 |
40 |
41 |
42 | 43 |
44 | Back to List 45 |
46 | 47 | @section Scripts { 48 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 49 | } 50 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Create.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class CreateModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public CreateModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public IActionResult OnGet() 23 | { 24 | return Page(); 25 | } 26 | 27 | [BindProperty] 28 | public Movie Movie { get; set; } = default!; 29 | 30 | 31 | // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD 32 | public async Task OnPostAsync() 33 | { 34 | if (!ModelState.IsValid || _context.Movie == null || Movie == null) 35 | { 36 | return Page(); 37 | } 38 | 39 | _context.Movie.Add(Movie); 40 | await _context.SaveChangesAsync(); 41 | 42 | return RedirectToPage("./Index"); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.DeleteModel 3 | 4 | @{ 5 | ViewData["Title"] = "Delete"; 6 | } 7 | 8 |

Delete

9 | 10 |

Are you sure you want to delete this?

11 |
12 |

Movie

13 |
14 |
15 |
16 | @Html.DisplayNameFor(model => model.Movie.Title) 17 |
18 |
19 | @Html.DisplayFor(model => model.Movie.Title) 20 |
21 |
22 | @Html.DisplayNameFor(model => model.Movie.ReleaseDate) 23 |
24 |
25 | @Html.DisplayFor(model => model.Movie.ReleaseDate) 26 |
27 |
28 | @Html.DisplayNameFor(model => model.Movie.Genre) 29 |
30 |
31 | @Html.DisplayFor(model => model.Movie.Genre) 32 |
33 |
34 | @Html.DisplayNameFor(model => model.Movie.Price) 35 |
36 |
37 | @Html.DisplayFor(model => model.Movie.Price) 38 |
39 |
40 | 41 |
42 | 43 | | 44 | Back to List 45 |
46 |
47 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Delete.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class DeleteModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public DeleteModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | [BindProperty] 23 | public Movie Movie { get; set; } = default!; 24 | 25 | public async Task OnGetAsync(int? id) 26 | { 27 | if (id == null || _context.Movie == null) 28 | { 29 | return NotFound(); 30 | } 31 | 32 | var movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 33 | 34 | if (movie == null) 35 | { 36 | return NotFound(); 37 | } 38 | else 39 | { 40 | Movie = movie; 41 | } 42 | return Page(); 43 | } 44 | 45 | public async Task OnPostAsync(int? id) 46 | { 47 | if (id == null || _context.Movie == null) 48 | { 49 | return NotFound(); 50 | } 51 | var movie = await _context.Movie.FindAsync(id); 52 | 53 | if (movie != null) 54 | { 55 | Movie = movie; 56 | _context.Movie.Remove(Movie); 57 | await _context.SaveChangesAsync(); 58 | } 59 | 60 | return RedirectToPage("./Index"); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Details.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.DetailsModel 3 | 4 | @{ 5 | ViewData["Title"] = "Details"; 6 | } 7 | 8 |

Details

9 | 10 |
11 |

Movie

12 |
13 |
14 |
15 | @Html.DisplayNameFor(model => model.Movie.Title) 16 |
17 |
18 | @Html.DisplayFor(model => model.Movie.Title) 19 |
20 |
21 | @Html.DisplayNameFor(model => model.Movie.ReleaseDate) 22 |
23 |
24 | @Html.DisplayFor(model => model.Movie.ReleaseDate) 25 |
26 |
27 | @Html.DisplayNameFor(model => model.Movie.Genre) 28 |
29 |
30 | @Html.DisplayFor(model => model.Movie.Genre) 31 |
32 |
33 | @Html.DisplayNameFor(model => model.Movie.Price) 34 |
35 |
36 | @Html.DisplayFor(model => model.Movie.Price) 37 |
38 |
39 |
40 |
41 | Edit | 42 | Back to List 43 |
44 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Details.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class DetailsModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public DetailsModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public Movie Movie { get; set; } = default!; 23 | 24 | public async Task OnGetAsync(int? id) 25 | { 26 | if (id == null || _context.Movie == null) 27 | { 28 | return NotFound(); 29 | } 30 | 31 | var movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 32 | if (movie == null) 33 | { 34 | return NotFound(); 35 | } 36 | else 37 | { 38 | Movie = movie; 39 | } 40 | return Page(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.EditModel 3 | 4 | @{ 5 | ViewData["Title"] = "Edit"; 6 | } 7 | 8 |

Edit

9 | 10 |

Movie

11 |
12 |
13 |
14 |
15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 |
27 |
28 | 29 | 30 | 31 |
32 |
33 | 34 | 35 | 36 |
37 |
38 | 39 |
40 |
41 |
42 |
43 | 44 |
45 | Back to List 46 |
47 | 48 | @section Scripts { 49 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 50 | } 51 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Edit.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using Microsoft.EntityFrameworkCore; 9 | using RazorPagesMovie.Data; 10 | using RazorPagesMovie.Models; 11 | 12 | namespace RazorPagesMovie.Pages.Movies 13 | { 14 | public class EditModel : PageModel 15 | { 16 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 17 | 18 | public EditModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | [BindProperty] 24 | public Movie Movie { get; set; } = default!; 25 | 26 | public async Task OnGetAsync(int? id) 27 | { 28 | if (id == null || _context.Movie == null) 29 | { 30 | return NotFound(); 31 | } 32 | 33 | var movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 34 | if (movie == null) 35 | { 36 | return NotFound(); 37 | } 38 | Movie = movie; 39 | return Page(); 40 | } 41 | 42 | // To protect from overposting attacks, enable the specific properties you want to bind to. 43 | // For more details, see https://aka.ms/RazorPagesCRUD. 44 | public async Task OnPostAsync() 45 | { 46 | if (!ModelState.IsValid) 47 | { 48 | return Page(); 49 | } 50 | 51 | _context.Attach(Movie).State = EntityState.Modified; 52 | 53 | try 54 | { 55 | await _context.SaveChangesAsync(); 56 | } 57 | catch (DbUpdateConcurrencyException) 58 | { 59 | if (!MovieExists(Movie.ID)) 60 | { 61 | return NotFound(); 62 | } 63 | else 64 | { 65 | throw; 66 | } 67 | } 68 | 69 | return RedirectToPage("./Index"); 70 | } 71 | 72 | private bool MovieExists(int id) 73 | { 74 | return (_context.Movie?.Any(e => e.ID == id)).GetValueOrDefault(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.IndexModel 3 | 4 | @{ 5 | ViewData["Title"] = "Index"; 6 | } 7 | 8 |

Index

9 | 10 |

11 | Create New 12 |

13 | 14 | 15 | 16 | 19 | 22 | 25 | 28 | 29 | 30 | 31 | 32 | @foreach (var item in Model.Movie) { 33 | 34 | 37 | 40 | 43 | 46 | 51 | 52 | } 53 | 54 |
17 | @Html.DisplayNameFor(model => model.Movie[0].Title) 18 | 20 | @Html.DisplayNameFor(model => model.Movie[0].ReleaseDate) 21 | 23 | @Html.DisplayNameFor(model => model.Movie[0].Genre) 24 | 26 | @Html.DisplayNameFor(model => model.Movie[0].Price) 27 |
35 | @Html.DisplayFor(modelItem => item.Title) 36 | 38 | @Html.DisplayFor(modelItem => item.ReleaseDate) 39 | 41 | @Html.DisplayFor(modelItem => item.Genre) 42 | 44 | @Html.DisplayFor(modelItem => item.Price) 45 | 47 | Edit | 48 | Details | 49 | Delete 50 |
55 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Movies/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class IndexModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public IndexModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public IList Movie { get;set; } = default!; 23 | 24 | public async Task OnGetAsync() 25 | { 26 | if (_context.Movie != null) 27 | { 28 | Movie = await _context.Movie.ToListAsync(); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model PrivacyModel 3 | @{ 4 | ViewData["Title"] = "Privacy Policy"; 5 | } 6 |

@ViewData["Title"]

7 | 8 |

Use this page to detail your site's privacy policy.

9 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Privacy.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages 5 | { 6 | public class PrivacyModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public PrivacyModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - RazorPagesMovie 7 | 8 | 9 | 10 | 11 | 12 |
13 | 32 |
33 |
34 |
35 | @RenderBody() 36 |
37 |
38 | 39 |
40 |
41 | © 2023 - RazorPagesMovie - Privacy 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | @await RenderSectionAsync("Scripts", required: false) 50 | 51 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Shared/_Layout.cshtml.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using RazorPagesMovie 2 | @namespace RazorPagesMovie.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using RazorPagesMovie.Data; 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | // Add services to the container. 7 | builder.Services.AddRazorPages(); 8 | builder.Services.AddDbContext(options => 9 | options.UseSqlite(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found."))); 10 | 11 | var app = builder.Build(); 12 | 13 | // Configure the HTTP request pipeline. 14 | if (!app.Environment.IsDevelopment()) 15 | { 16 | app.UseExceptionHandler("/Error"); 17 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 18 | app.UseHsts(); 19 | } 20 | 21 | app.UseHttpsRedirection(); 22 | app.UseStaticFiles(); 23 | 24 | app.UseRouting(); 25 | 26 | app.UseAuthorization(); 27 | 28 | app.MapRazorPages(); 29 | 30 | app.Run(); 31 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql", 5 | "connectionId": "ConnectionStrings:RazorPagesMovieContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql.local", 5 | "connectionId": "ConnectionStrings:RazorPagesMovieContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/RazorPagesMovie.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "RazorPagesMovieContext": "Data Source=MvcMovie.db" 11 | } 12 | } -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-size: 14px; 3 | } 4 | 5 | @media (min-width: 768px) { 6 | html { 7 | font-size: 16px; 8 | } 9 | } 10 | 11 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 12 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 13 | } 14 | 15 | html { 16 | position: relative; 17 | min-height: 100%; 18 | } 19 | 20 | body { 21 | margin-bottom: 60px; 22 | } -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/3-Update Pages/RazorPagesMovie/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2021 Twitter, Inc. 4 | Copyright (c) 2011-2021 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) .NET Foundation and Contributors 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/RazorPagesMovie/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright OpenJS Foundation and other contributors, https://openjsf.org/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/images/CurrentPage.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/3-Update Pages/images/CurrentPage.PNG -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/images/NewPage.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/3-Update Pages/images/NewPage.PNG -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/images/refactor_VS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/3-Update Pages/images/refactor_VS.png -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/images/refactor_VSMac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/3-Update Pages/images/refactor_VSMac.png -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/images/using_annotations_VS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/3-Update Pages/images/using_annotations_VS.png -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/images/using_annotations_VSMac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/3-Update Pages/images/using_annotations_VSMac.png -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/update-VS.md: -------------------------------------------------------------------------------- 1 | # Update pages in Visual Studio 2 | 3 | The following tutorial is based on [*"Get started with Razor Pages in ASP.NET Core"*](https://docs.microsoft.com/aspnet/core/tutorials/razor-pages/razor-pages-start) from docs.microsoft.com. 4 | 5 | ## Prerequisites 6 | 7 | * [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/?wt.mc_id=adw-brand&gclid=Cj0KCQjwqYfWBRDPARIsABjQRYwLe3b9dJMixA98s8nS8QfuNBKGsiRVRXzB93fe4E27LGK5KLrGcnYaAgdREALw_wcB) 8 | * In the Visual Studio Installer, install the following workload: 9 | * ASP.NET and web development 10 | * Tutorial 1- [Create a Razor Page application](../1-Create%20a%20Razor%20Page/Create-a-Razorpage-VS.md) 11 | * Tutorial 2- [Add a Model](../2-Add%20a%20model/Addamodel-VS.md) 12 | 13 | ## Update generated Pages 14 | 15 | ![](images/CurrentPage.PNG) 16 | 17 | In this tutorial, you're going to learn how to update the generated pages. For example, suppose you want to remove the time from the release date. 18 | 19 | 1. Open the `Models/Movie.cs` file. 20 | 1. Replace the contents of the `Movie.cs` file with the following code: 21 | 22 | ```csharp 23 | namespace RazorPagesMovie.Models; 24 | 25 | public class Movie 26 | { 27 | public int ID { get; set; } 28 | public string? Title { get; set; } 29 | 30 | [Display(Name = "Release Date")] 31 | [DataType(DataType.Date)] 32 | public DateTime ReleaseDate { get; set; } 33 | public string? Genre { get; set; } 34 | 35 | [Column(TypeName = "decimal(18, 2)")] 36 | public decimal Price { get; set; } 37 | } 38 | ``` 39 | 40 | 1. Press F5 to run the app. 41 | 1. Navigate to `https://localhost:{port}/Movies/Create` and notice the changes. 42 | 43 | ![](images/NewPage.PNG) 44 | 45 | 46 | **NEXT TUTORIAL:** [Adding search](../4-Add%20Search/SearchPage-VS.md) 47 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/update-VSMac.md: -------------------------------------------------------------------------------- 1 | # Update pages in Visual Studio for Mac 2 | 3 | The following tutorial is based on [*"Get started with Razor Pages in ASP.NET Core"*](https://docs.microsoft.com/aspnet/core/tutorials/razor-pages/razor-pages-start) from docs.microsoft.com. 4 | 5 | ## Prerequisites 6 | 7 | * [Visual Studio 2022 for Mac Preview](https://visualstudio.microsoft.com/vs/mac/preview/?wt.mc_id=adw-brand&gclid=Cj0KCQjwqYfWBRDPARIsABjQRYwLe3b9dJMixA98s8nS8QfuNBKGsiRVRXzB93fe4E27LGK5KLrGcnYaAgdREALw_wcB) 8 | * In the Visual Studio for Mac Installer, install the .NET Core target. 9 | * Tutorial 1- [Create a Razor Page application](../1-Create%20a%20Razor%20Page/Create-a-Razorpage-VSMac.md) 10 | * Tutorial 2- [Add a Model](../2-Add%20a%20model/Addamodel-VSMac.md) 11 | 12 | ## Update generated Pages 13 | 14 | ![](images/CurrentPage.PNG) 15 | 16 | In this tutorial, you're going to learn how to update the generated pages. For example, suppose you want to remove the time from the release date. 17 | 18 | 1. Open the `Models/Movie.cs` file. 19 | 1. Replace the contents of the `Movie.cs` file with the following code: 20 | 21 | ```csharp 22 | namespace RazorPagesMovie.Models; 23 | 24 | public class Movie 25 | { 26 | public int ID { get; set; } 27 | public string? Title { get; set; } 28 | 29 | [Display(Name = "Release Date")] 30 | [DataType(DataType.Date)] 31 | public DateTime ReleaseDate { get; set; } 32 | 33 | public string? Genre { get; set; } 34 | 35 | [Column(TypeName = "decimal(18, 2)")] 36 | public decimal Price { get; set; } 37 | } 38 | ``` 39 | 40 | * Right click on a red line and select **Quick Actions and Refactorings** on the [Display] attribute. 41 | 42 | ![](images/refactor_VSMac.png) 43 | 44 | 1. Select **using System.ComponentModel.DataAnnotations;**. 45 | 46 | ![](images/using_annotations_VSMac.png) 47 | 48 | 1. Right click on the remaining red line, select **Quick Actions and Refactorings** on the [Column] attribute. 49 | 1. Select **using System.ComponentModel.DataAnnotations.Schema;**. 50 | 1. Run the application by selecting **Debug** > **Start without Debugging** on the main menu. 51 | 1. Navigate to `https://localhost:{port}/Movies/Create` and notice the changes. 52 | 53 | ![](images/NewPage.PNG) 54 | 55 | **NEXT TUTORIAL:** [Adding search](../4-Add%20Search/SearchPage-VSMac.md) 56 | -------------------------------------------------------------------------------- /Tutorial/3-Update Pages/update.md: -------------------------------------------------------------------------------- 1 | # Update pages in Visual Studio Code 2 | 3 | The following tutorial is based on [*"Get started with ASP.NET Core Razor Pages in Visual Studio Code"*](https://docs.microsoft.com/aspnet/core/tutorials/razor-pages-vsc/razor-pages-start) from docs.microsoft.com. 4 | 5 | ## Prerequisites 6 | 7 | * [.NET 7 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) 8 | * [Visual Studio Code](https://code.visualstudio.com/?wt.mc_id=adw-brand&gclid=Cj0KCQjwqYfWBRDPARIsABjQRYwLe3b9dJMixA98s8nS8QfuNBKGsiRVRXzB93fe4E27LGK5KLrGcnYaAgdREALw_wcB) 9 | * Tutorial 1- [Create a Razor Page application](../1-Create%20a%20Razor%20Page/Create-a-Razorpage.md) 10 | * Tutorial 2- [Add a Model](../2-Add%20a%20model/Addamodel.md) 11 | 12 | ## Update generated Pages 13 | 14 | ![](images/CurrentPage.PNG) 15 | 16 | In this tutorial, you're going to learn how to update the generated pages. For example, suppose you want to remove the time from the release date. 17 | 18 | 1. Open the `Models/Movie.cs` file. 19 | 1. Add the following using statements to the top of the file: 20 | 21 | ```csharp 22 | using System.ComponentModel.DataAnnotations; 23 | using System.ComponentModel.DataAnnotations.Schema; 24 | ``` 25 | 26 | 1. Add the [following data annotations](https://docs.microsoft.com/aspnet/mvc/overview/older-versions/mvc-music-store/mvc-music-store-part-6): 27 | `[Display(Name = "Release Date")]` and `[DataType(DataType.Date)]` to the `ReleaseDate` property as shown in the following code: 28 | 29 | ``` cs 30 | using System.ComponentModel.DataAnnotations; 31 | using System.ComponentModel.DataAnnotations.Schema; 32 | namespace RazorPagesMovie.Models; 33 | 34 | public class Movie 35 | { 36 | public int ID { get; set; } 37 | public string? Title { get; set; } 38 | 39 | [Display(Name = "Release Date")] 40 | [DataType(DataType.Date)] 41 | public DateTime ReleaseDate { get; set; } 42 | 43 | public string? Genre { get; set; } 44 | 45 | [Column(TypeName = "decimal(18, 2)")] 46 | public decimal Price { get; set; } 47 | } 48 | ``` 49 | 50 | 1. Run the app using the `dotnet run` command. 51 | 1. Navigate to `https://localhost:{port}/Movies/Create` and notice the changes. 52 | 53 | ![](images/NewPage.PNG) 54 | 55 | **NEXT TUTORIAL:** [Adding search](../4-Add%20Search/SearchPage.md) 56 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/RazorPagesMovie/bin/Debug/netcoreapp2.2/RazorPagesMovie.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/RazorPagesMovie", 16 | "stopAtEntry": false, 17 | "internalConsoleOptions": "openOnSessionStart", 18 | "launchBrowser": { 19 | "enabled": true, 20 | "args": "${auto-detect-url}", 21 | "windows": { 22 | "command": "cmd.exe", 23 | "args": "/C start ${auto-detect-url}" 24 | }, 25 | "osx": { 26 | "command": "open" 27 | }, 28 | "linux": { 29 | "command": "xdg-open" 30 | } 31 | }, 32 | "env": { 33 | "ASPNETCORE_ENVIRONMENT": "Development" 34 | }, 35 | "sourceFileMap": { 36 | "/Views": "${workspaceFolder}/Views" 37 | } 38 | }, 39 | { 40 | "name": ".NET Core Attach", 41 | "type": "coreclr", 42 | "request": "attach", 43 | "processId": "${command:pickProcess}" 44 | } 45 | ,] 46 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/RazorPagesMovie/RazorPagesMovie.csproj" 11 | ], 12 | "problemMatcher": "$msCompile" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Data/RazorPagesMovieContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using RazorPagesMovie.Models; 7 | 8 | namespace RazorPagesMovie.Data 9 | { 10 | public class RazorPagesMovieContext : DbContext 11 | { 12 | public RazorPagesMovieContext (DbContextOptions options) 13 | : base(options) 14 | { 15 | } 16 | 17 | public DbSet Movie { get; set; } = default!; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Migrations/20230411061819_Initial.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 7 | using RazorPagesMovie.Data; 8 | 9 | #nullable disable 10 | 11 | namespace RazorPagesMovie.Migrations 12 | { 13 | [DbContext(typeof(RazorPagesMovieContext))] 14 | [Migration("20230411061819_Initial")] 15 | partial class Initial 16 | { 17 | /// 18 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 19 | { 20 | #pragma warning disable 612, 618 21 | modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); 22 | 23 | modelBuilder.Entity("RazorPagesMovie.Models.Movie", b => 24 | { 25 | b.Property("ID") 26 | .ValueGeneratedOnAdd() 27 | .HasColumnType("INTEGER"); 28 | 29 | b.Property("Genre") 30 | .HasColumnType("TEXT"); 31 | 32 | b.Property("Price") 33 | .HasColumnType("TEXT"); 34 | 35 | b.Property("ReleaseDate") 36 | .HasColumnType("TEXT"); 37 | 38 | b.Property("Title") 39 | .HasColumnType("TEXT"); 40 | 41 | b.HasKey("ID"); 42 | 43 | b.ToTable("Movie"); 44 | }); 45 | #pragma warning restore 612, 618 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Migrations/20230411061819_Initial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | #nullable disable 5 | 6 | namespace RazorPagesMovie.Migrations 7 | { 8 | /// 9 | public partial class Initial : Migration 10 | { 11 | /// 12 | protected override void Up(MigrationBuilder migrationBuilder) 13 | { 14 | migrationBuilder.CreateTable( 15 | name: "Movie", 16 | columns: table => new 17 | { 18 | ID = table.Column(type: "INTEGER", nullable: false) 19 | .Annotation("Sqlite:Autoincrement", true), 20 | Title = table.Column(type: "TEXT", nullable: true), 21 | ReleaseDate = table.Column(type: "TEXT", nullable: false), 22 | Genre = table.Column(type: "TEXT", nullable: true), 23 | Price = table.Column(type: "TEXT", nullable: false) 24 | }, 25 | constraints: table => 26 | { 27 | table.PrimaryKey("PK_Movie", x => x.ID); 28 | }); 29 | } 30 | 31 | /// 32 | protected override void Down(MigrationBuilder migrationBuilder) 33 | { 34 | migrationBuilder.DropTable( 35 | name: "Movie"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Migrations/RazorPagesMovieContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 6 | using RazorPagesMovie.Data; 7 | 8 | #nullable disable 9 | 10 | namespace RazorPagesMovie.Migrations 11 | { 12 | [DbContext(typeof(RazorPagesMovieContext))] 13 | partial class RazorPagesMovieContextModelSnapshot : ModelSnapshot 14 | { 15 | protected override void BuildModel(ModelBuilder modelBuilder) 16 | { 17 | #pragma warning disable 612, 618 18 | modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); 19 | 20 | modelBuilder.Entity("RazorPagesMovie.Models.Movie", b => 21 | { 22 | b.Property("ID") 23 | .ValueGeneratedOnAdd() 24 | .HasColumnType("INTEGER"); 25 | 26 | b.Property("Genre") 27 | .HasColumnType("TEXT"); 28 | 29 | b.Property("Price") 30 | .HasColumnType("TEXT"); 31 | 32 | b.Property("ReleaseDate") 33 | .HasColumnType("TEXT"); 34 | 35 | b.Property("Title") 36 | .HasColumnType("TEXT"); 37 | 38 | b.HasKey("ID"); 39 | 40 | b.ToTable("Movie"); 41 | }); 42 | #pragma warning restore 612, 618 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Models/Movie.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Metadata.Internal; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | namespace RazorPagesMovie.Models; 6 | 7 | public class Movie 8 | { 9 | public int ID { get; set; } 10 | public string? Title { get; set; } 11 | 12 | [Display(Name = "Release Date")] 13 | [DataType(DataType.Date)] 14 | public DateTime ReleaseDate { get; set; } 15 | public string? Genre { get; set; } 16 | 17 | [Column(TypeName = "decimal(18, 2)")] 18 | public decimal Price { get; set; } 19 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/MvcMovie.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/4-Add Search/RazorPagesMovie/MvcMovie.db -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace RazorPagesMovie.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 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model IndexModel 3 | @{ 4 | ViewData["Title"] = "Home page"; 5 | } 6 | 7 |
8 |

Welcome

9 |

Learn about building Web apps with ASP.NET Core.

10 |
11 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages 5 | { 6 | public class IndexModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public IndexModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Create.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.CreateModel 3 | 4 | @{ 5 | ViewData["Title"] = "Create"; 6 | } 7 | 8 |

Create

9 | 10 |

Movie

11 |
12 |
13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 |
37 | 38 |
39 |
40 |
41 |
42 | 43 |
44 | Back to List 45 |
46 | 47 | @section Scripts { 48 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 49 | } 50 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Create.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class CreateModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public CreateModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public IActionResult OnGet() 23 | { 24 | return Page(); 25 | } 26 | 27 | [BindProperty] 28 | public Movie Movie { get; set; } = default!; 29 | 30 | 31 | // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD 32 | public async Task OnPostAsync() 33 | { 34 | if (!ModelState.IsValid || _context.Movie == null || Movie == null) 35 | { 36 | return Page(); 37 | } 38 | 39 | _context.Movie.Add(Movie); 40 | await _context.SaveChangesAsync(); 41 | 42 | return RedirectToPage("./Index"); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.DeleteModel 3 | 4 | @{ 5 | ViewData["Title"] = "Delete"; 6 | } 7 | 8 |

Delete

9 | 10 |

Are you sure you want to delete this?

11 |
12 |

Movie

13 |
14 |
15 |
16 | @Html.DisplayNameFor(model => model.Movie.Title) 17 |
18 |
19 | @Html.DisplayFor(model => model.Movie.Title) 20 |
21 |
22 | @Html.DisplayNameFor(model => model.Movie.ReleaseDate) 23 |
24 |
25 | @Html.DisplayFor(model => model.Movie.ReleaseDate) 26 |
27 |
28 | @Html.DisplayNameFor(model => model.Movie.Genre) 29 |
30 |
31 | @Html.DisplayFor(model => model.Movie.Genre) 32 |
33 |
34 | @Html.DisplayNameFor(model => model.Movie.Price) 35 |
36 |
37 | @Html.DisplayFor(model => model.Movie.Price) 38 |
39 |
40 | 41 |
42 | 43 | | 44 | Back to List 45 |
46 |
47 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Delete.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class DeleteModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public DeleteModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | [BindProperty] 23 | public Movie Movie { get; set; } = default!; 24 | 25 | public async Task OnGetAsync(int? id) 26 | { 27 | if (id == null || _context.Movie == null) 28 | { 29 | return NotFound(); 30 | } 31 | 32 | var movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 33 | 34 | if (movie == null) 35 | { 36 | return NotFound(); 37 | } 38 | else 39 | { 40 | Movie = movie; 41 | } 42 | return Page(); 43 | } 44 | 45 | public async Task OnPostAsync(int? id) 46 | { 47 | if (id == null || _context.Movie == null) 48 | { 49 | return NotFound(); 50 | } 51 | var movie = await _context.Movie.FindAsync(id); 52 | 53 | if (movie != null) 54 | { 55 | Movie = movie; 56 | _context.Movie.Remove(Movie); 57 | await _context.SaveChangesAsync(); 58 | } 59 | 60 | return RedirectToPage("./Index"); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Details.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.DetailsModel 3 | 4 | @{ 5 | ViewData["Title"] = "Details"; 6 | } 7 | 8 |

Details

9 | 10 |
11 |

Movie

12 |
13 |
14 |
15 | @Html.DisplayNameFor(model => model.Movie.Title) 16 |
17 |
18 | @Html.DisplayFor(model => model.Movie.Title) 19 |
20 |
21 | @Html.DisplayNameFor(model => model.Movie.ReleaseDate) 22 |
23 |
24 | @Html.DisplayFor(model => model.Movie.ReleaseDate) 25 |
26 |
27 | @Html.DisplayNameFor(model => model.Movie.Genre) 28 |
29 |
30 | @Html.DisplayFor(model => model.Movie.Genre) 31 |
32 |
33 | @Html.DisplayNameFor(model => model.Movie.Price) 34 |
35 |
36 | @Html.DisplayFor(model => model.Movie.Price) 37 |
38 |
39 |
40 |
41 | Edit | 42 | Back to List 43 |
44 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Details.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using RazorPagesMovie.Data; 9 | using RazorPagesMovie.Models; 10 | 11 | namespace RazorPagesMovie.Pages.Movies 12 | { 13 | public class DetailsModel : PageModel 14 | { 15 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 16 | 17 | public DetailsModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public Movie Movie { get; set; } = default!; 23 | 24 | public async Task OnGetAsync(int? id) 25 | { 26 | if (id == null || _context.Movie == null) 27 | { 28 | return NotFound(); 29 | } 30 | 31 | var movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 32 | if (movie == null) 33 | { 34 | return NotFound(); 35 | } 36 | else 37 | { 38 | Movie = movie; 39 | } 40 | return Page(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.EditModel 3 | 4 | @{ 5 | ViewData["Title"] = "Edit"; 6 | } 7 | 8 |

Edit

9 | 10 |

Movie

11 |
12 |
13 |
14 |
15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 |
27 |
28 | 29 | 30 | 31 |
32 |
33 | 34 | 35 | 36 |
37 |
38 | 39 |
40 |
41 |
42 |
43 | 44 |
45 | Back to List 46 |
47 | 48 | @section Scripts { 49 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 50 | } 51 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Edit.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using Microsoft.EntityFrameworkCore; 9 | using RazorPagesMovie.Data; 10 | using RazorPagesMovie.Models; 11 | 12 | namespace RazorPagesMovie.Pages.Movies 13 | { 14 | public class EditModel : PageModel 15 | { 16 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 17 | 18 | public EditModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | [BindProperty] 24 | public Movie Movie { get; set; } = default!; 25 | 26 | public async Task OnGetAsync(int? id) 27 | { 28 | if (id == null || _context.Movie == null) 29 | { 30 | return NotFound(); 31 | } 32 | 33 | var movie = await _context.Movie.FirstOrDefaultAsync(m => m.ID == id); 34 | if (movie == null) 35 | { 36 | return NotFound(); 37 | } 38 | Movie = movie; 39 | return Page(); 40 | } 41 | 42 | // To protect from overposting attacks, enable the specific properties you want to bind to. 43 | // For more details, see https://aka.ms/RazorPagesCRUD. 44 | public async Task OnPostAsync() 45 | { 46 | if (!ModelState.IsValid) 47 | { 48 | return Page(); 49 | } 50 | 51 | _context.Attach(Movie).State = EntityState.Modified; 52 | 53 | try 54 | { 55 | await _context.SaveChangesAsync(); 56 | } 57 | catch (DbUpdateConcurrencyException) 58 | { 59 | if (!MovieExists(Movie.ID)) 60 | { 61 | return NotFound(); 62 | } 63 | else 64 | { 65 | throw; 66 | } 67 | } 68 | 69 | return RedirectToPage("./Index"); 70 | } 71 | 72 | private bool MovieExists(int id) 73 | { 74 | return (_context.Movie?.Any(e => e.ID == id)).GetValueOrDefault(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesMovie.Pages.Movies.IndexModel 3 | 4 | @{ 5 | ViewData["Title"] = "Index"; 6 | } 7 | 8 |

Index

9 | 10 |

11 | Create New 12 |

13 |
14 |

15 | 18 | 19 | Movie Title: 20 | 21 |

22 |
23 | 24 | 25 | 26 | 29 | 32 | 35 | 38 | 39 | 40 | 41 | 42 | @foreach (var item in Model.Movie) { 43 | 44 | 47 | 50 | 53 | 56 | 61 | 62 | } 63 | 64 |
27 | @Html.DisplayNameFor(model => model.Movie[0].Title) 28 | 30 | @Html.DisplayNameFor(model => model.Movie[0].ReleaseDate) 31 | 33 | @Html.DisplayNameFor(model => model.Movie[0].Genre) 34 | 36 | @Html.DisplayNameFor(model => model.Movie[0].Price) 37 |
45 | @Html.DisplayFor(modelItem => item.Title) 46 | 48 | @Html.DisplayFor(modelItem => item.ReleaseDate) 49 | 51 | @Html.DisplayFor(modelItem => item.Genre) 52 | 54 | @Html.DisplayFor(modelItem => item.Price) 55 | 57 | Edit | 58 | Details | 59 | Delete 60 |
65 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Movies/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using Microsoft.EntityFrameworkCore; 9 | using RazorPagesMovie.Data; 10 | using RazorPagesMovie.Models; 11 | 12 | namespace RazorPagesMovie.Pages.Movies 13 | { 14 | public class IndexModel : PageModel 15 | { 16 | private readonly RazorPagesMovie.Data.RazorPagesMovieContext _context; 17 | 18 | public IndexModel(RazorPagesMovie.Data.RazorPagesMovieContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | public IList Movie { get;set; } = default!; 24 | public SelectList Genres; 25 | public string MovieGenre { get; set; } 26 | 27 | public async Task OnGetAsync(string movieGenre, string searchString) 28 | { 29 | IQueryable genreQuery = from m in _context.Movie 30 | orderby m.Genre 31 | select m.Genre; 32 | 33 | var movies = from m in _context.Movie 34 | select m; 35 | 36 | if (!String.IsNullOrEmpty(searchString)) 37 | { 38 | movies = movies.Where(s => s.Title.Contains(searchString)); 39 | } 40 | 41 | if (!String.IsNullOrEmpty(movieGenre)) 42 | { 43 | movies = movies.Where(x => x.Genre == movieGenre); 44 | } 45 | Genres = new SelectList(await genreQuery.Distinct().ToListAsync()); 46 | Movie = await movies.ToListAsync(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model PrivacyModel 3 | @{ 4 | ViewData["Title"] = "Privacy Policy"; 5 | } 6 |

@ViewData["Title"]

7 | 8 |

Use this page to detail your site's privacy policy.

9 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Privacy.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesMovie.Pages 5 | { 6 | public class PrivacyModel : PageModel 7 | { 8 | private readonly ILogger _logger; 9 | 10 | public PrivacyModel(ILogger logger) 11 | { 12 | _logger = logger; 13 | } 14 | 15 | public void OnGet() 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - RazorPagesMovie 7 | 8 | 9 | 10 | 11 | 12 |
13 | 32 |
33 |
34 |
35 | @RenderBody() 36 |
37 |
38 | 39 |
40 |
41 | © 2023 - RazorPagesMovie - Privacy 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | @await RenderSectionAsync("Scripts", required: false) 50 | 51 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Shared/_Layout.cshtml.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using RazorPagesMovie 2 | @namespace RazorPagesMovie.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using RazorPagesMovie.Data; 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | // Add services to the container. 7 | builder.Services.AddRazorPages(); 8 | builder.Services.AddDbContext(options => 9 | options.UseSqlite(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found."))); 10 | 11 | var app = builder.Build(); 12 | 13 | // Configure the HTTP request pipeline. 14 | if (!app.Environment.IsDevelopment()) 15 | { 16 | app.UseExceptionHandler("/Error"); 17 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 18 | app.UseHsts(); 19 | } 20 | 21 | app.UseHttpsRedirection(); 22 | app.UseStaticFiles(); 23 | 24 | app.UseRouting(); 25 | 26 | app.UseAuthorization(); 27 | 28 | app.MapRazorPages(); 29 | 30 | app.Run(); 31 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql", 5 | "connectionId": "ConnectionStrings:RazorPagesMovieContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql.local", 5 | "connectionId": "ConnectionStrings:RazorPagesMovieContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/RazorPagesMovie.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "RazorPagesMovieContext": "Data Source=MvcMovie.db" 11 | } 12 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-size: 14px; 3 | } 4 | 5 | @media (min-width: 768px) { 6 | html { 7 | font-size: 16px; 8 | } 9 | } 10 | 11 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 12 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 13 | } 14 | 15 | html { 16 | position: relative; 17 | min-height: 100%; 18 | } 19 | 20 | body { 21 | margin-bottom: 60px; 22 | } -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/4-Add Search/RazorPagesMovie/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2021 Twitter, Inc. 4 | Copyright (c) 2011-2021 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) .NET Foundation and Contributors 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Tutorial/4-Add Search/RazorPagesMovie/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright OpenJS Foundation and other contributors, https://openjsf.org/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Tutorial/4-Add Search/images/genre.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/4-Add Search/images/genre.PNG -------------------------------------------------------------------------------- /Tutorial/4-Add Search/images/searchString.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/4-Add Search/images/searchString.PNG -------------------------------------------------------------------------------- /Tutorial/4-Add Search/images/searchform.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/Tutorial/4-Add Search/images/searchform.PNG -------------------------------------------------------------------------------- /deck/ASP.NETCore_Beginners.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-presentations/aspnetcore-for-beginners/322ba2b2ee07d3b48efe78da94f13090f97cfbc3/deck/ASP.NETCore_Beginners.pptx --------------------------------------------------------------------------------