├── .devcontainer └── devcontainer.json ├── .github └── workflows │ └── dotnet.yml ├── .gitignore ├── 1-welcome ├── README.md └── how-to-install-vs.md ├── 2-csharp ├── README.md ├── lesson-2-projects │ ├── challenge-project │ │ ├── Final │ │ │ ├── Final.csproj │ │ │ └── Program.cs │ │ ├── LICENSE │ │ ├── README.md │ │ └── Starter │ │ │ ├── Program.cs │ │ │ └── Starter.csproj │ └── guided-project │ │ ├── Final │ │ ├── Final.csproj │ │ └── Program.cs │ │ ├── LICENSE │ │ ├── README.md │ │ └── Starter │ │ ├── Program.cs │ │ └── Starter.csproj ├── lesson-3-projects │ ├── challenge-project │ │ ├── Final │ │ │ ├── Final.csproj │ │ │ └── Program.cs │ │ ├── LICENSE │ │ ├── README.md │ │ └── Starter │ │ │ ├── Program.cs │ │ │ └── Starter.csproj │ └── guided-project │ │ ├── Final │ │ ├── Final.csproj │ │ └── Program.cs │ │ ├── LICENSE │ │ ├── README.md │ │ └── Starter │ │ ├── Program.cs │ │ └── Starter.csproj ├── lesson-4-projects │ ├── challenge-project │ │ ├── Final │ │ │ ├── Final.csproj │ │ │ └── Program.cs │ │ ├── LICENSE │ │ ├── README.md │ │ └── Starter │ │ │ ├── Program.cs │ │ │ └── Starter.csproj │ └── guided-project │ │ ├── Final │ │ ├── Final.csproj │ │ └── Program.cs │ │ ├── LICENSE │ │ ├── README.md │ │ └── Starter │ │ ├── Program.cs │ │ └── Starter.csproj ├── lesson-5-projects │ └── challenge-project │ │ ├── Final │ │ ├── Final.csproj │ │ └── Program.cs │ │ ├── LICENSE │ │ ├── README.md │ │ └── Starter │ │ ├── Program.cs │ │ └── Starter.csproj └── lesson-6-projects │ ├── challenge-project │ ├── Final │ │ ├── Final.csproj │ │ └── Program.cs │ ├── LICENSE │ ├── README.md │ └── Starter │ │ ├── Program.cs │ │ └── Starter.csproj │ └── guided-project │ ├── Final │ ├── Final.csproj │ └── Program.cs │ ├── LICENSE │ ├── README.md │ └── Starter │ ├── Program.cs │ └── Starter.csproj ├── 3-razor-pages ├── 0-start │ └── RazorPagesPizza │ │ ├── RazorPagesPizza.sln │ │ └── RazorPagesPizza │ │ ├── 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 │ │ ├── Properties │ │ └── launchSettings.json │ │ ├── RazorPagesPizza.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 ├── 1-complete │ └── RazorPagesPizza │ │ ├── RazorPagesPizza.sln │ │ └── RazorPagesPizza │ │ ├── Data │ │ └── RazorPagesPizzaContext.cs │ │ ├── Migrations │ │ ├── 20230630173639_InitialCreate.Designer.cs │ │ ├── 20230630173639_InitialCreate.cs │ │ └── RazorPagesPizzaContextModelSnapshot.cs │ │ ├── Models │ │ └── Pizza.cs │ │ ├── Pages │ │ ├── Create.cshtml │ │ ├── Create.cshtml.cs │ │ ├── Delete.cshtml │ │ ├── Delete.cshtml.cs │ │ ├── Details.cshtml │ │ ├── Details.cshtml.cs │ │ ├── Edit.cshtml │ │ ├── Edit.cshtml.cs │ │ ├── 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 │ │ ├── Properties │ │ ├── launchSettings.json │ │ ├── serviceDependencies.json │ │ └── serviceDependencies.local.json │ │ ├── RazorPagesPizza.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 ├── README.md ├── add-scaffold.png ├── additional-info.png ├── config.png ├── new-scaffold-dialog.png ├── np.png ├── overwrite-warning.png ├── pizza-list.png ├── pmc.png ├── scaffold-settings.png ├── se.png └── start-window-create-new-project.png ├── 4-minimal-api ├── 0-start │ └── PizzaStore │ │ ├── PizzaStore.csproj │ │ ├── Program.cs │ │ ├── Properties │ │ └── launchSettings.json │ │ ├── appsettings.Development.json │ │ └── appsettings.json ├── 1-complete │ └── PizzaStore │ │ ├── Db.cs │ │ ├── PizzaStore.csproj │ │ ├── Program.cs │ │ ├── Properties │ │ └── launchSettings.json │ │ ├── appsettings.Development.json │ │ └── appsettings.json ├── README.md ├── swagger-crud.png └── swagger.png ├── 5-blazor ├── 0-start │ ├── Blazor.ConnectFour.sln │ └── ConnectFour │ │ ├── Components │ │ ├── App.razor │ │ ├── Board.razor │ │ ├── Board.razor.css │ │ ├── Layout │ │ │ ├── MainLayout.razor │ │ │ ├── MainLayout.razor.css │ │ │ ├── NavMenu.razor │ │ │ └── NavMenu.razor.css │ │ ├── Pages │ │ │ ├── Counter.razor │ │ │ ├── Error.razor │ │ │ ├── Home.razor │ │ │ └── Weather.razor │ │ ├── Routes.razor │ │ └── _Imports.razor │ │ ├── ConnectFour.csproj │ │ ├── GameState.cs │ │ ├── Program.cs │ │ ├── Properties │ │ └── launchSettings.json │ │ └── wwwroot │ │ ├── app.css │ │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── favicon.png ├── 1-complete │ ├── Blazor.ConnectFour.sln │ └── ConnectFour │ │ ├── Components │ │ ├── App.razor │ │ ├── Board.razor │ │ ├── Board.razor.css │ │ ├── Layout │ │ │ ├── MainLayout.razor │ │ │ ├── MainLayout.razor.css │ │ │ ├── NavMenu.razor │ │ │ └── NavMenu.razor.css │ │ ├── Pages │ │ │ ├── Error.razor │ │ │ └── Home.razor │ │ ├── Routes.razor │ │ └── _Imports.razor │ │ ├── ConnectFour.csproj │ │ ├── GameState.cs │ │ ├── Program.cs │ │ ├── Properties │ │ └── launchSettings.json │ │ └── wwwroot │ │ ├── app.css │ │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── favicon.png ├── README.md └── img │ ├── 1-NewTemplate.png │ ├── 2-Board-Step1.png │ ├── 2-Board-Step2.png │ ├── 2-Board-Step3.png │ ├── 2-board-drop.gif │ ├── 3-Board-ErrorHandler.png │ ├── 3-Board-Step1.png │ ├── 3-Board-Step2.png │ └── 4-Board.png ├── 6-publish ├── README.md └── images │ ├── azure-customer-agreement.png │ ├── azure-start-free.png │ ├── create-new-app-service.png │ ├── hosting-plan.png │ ├── publish-new-app-service.png │ ├── sign-in-azure.png │ ├── solution-explorer-publish.png │ └── specific-target.png ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md └── images ├── dotnet-bot.svg ├── dotnet-bot_jetpack-faceing-right.svg ├── intro-thumbnail.jpg └── what-is-dotnet.png /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the 2 | // README at: https://github.com/devcontainers/templates/tree/main/src/dotnet 3 | { 4 | "name": "Intro to .NET webdev", 5 | // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile 6 | "image": "mcr.microsoft.com/devcontainers/dotnet:8.0", 7 | 8 | // Features to add to the dev container. More info: https://containers.dev/features. 9 | "features": {}, 10 | 11 | "customizations": { 12 | "vscode": { 13 | "extensions": [ 14 | "ms-dotnettools.csdevkit" 15 | ] 16 | } 17 | }, 18 | "forwardPorts": [ 19 | 5007, 20 | 5101, 21 | 5112 22 | ], 23 | "postCreateCommand": "dotnet restore", 24 | "portsAttributes": { 25 | "5007": { 26 | "label": "Blazor Connect Four" 27 | }, 28 | "5101": { 29 | "label": "RazorPagesPizza" 30 | }, 31 | "5112": { 32 | "label": "Pizza API" 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a .NET project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net 3 | 4 | name: .NET Build 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | env: 13 | DOTNET_VERSION: '8.0.x' # The .NET SDK version to use 14 | 15 | jobs: 16 | build: 17 | name: Build All Projects 18 | runs-on: ubuntu-latest 19 | 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | project: 24 | - 3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/RazorPagesPizza.csproj 25 | - 3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/RazorPagesPizza.csproj 26 | - 4-minimal-api/0-start/PizzaStore/PizzaStore.csproj 27 | - 4-minimal-api/1-complete/PizzaStore/PizzaStore.csproj 28 | - 5-blazor/0-start/ConnectFour/ConnectFour.csproj 29 | - 5-blazor/1-complete/ConnectFour/ConnectFour.csproj 30 | 31 | steps: 32 | - uses: actions/checkout@v3 33 | - name: Setup .NET 34 | uses: actions/setup-dotnet@v3 35 | with: 36 | dotnet-version: ${{ env.DOTNET_VERSION }} 37 | - name: Build ${{ matrix.project }} 38 | run: dotnet build "${{ matrix.project }}" 39 | -------------------------------------------------------------------------------- /1-welcome/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to the Intro to Web Dev with .NET series 2 | In this Welcome, we’ll introduce ourselves, give you the lesson rundown, take you on a tour of the .NET ecosystem, and show you all the tools you’ll need to build the projects. 3 | 4 | ![.NET bot waving](../images/dotnet-bot.svg) 5 | 6 | ## Prerequisite tools 7 | In this series, you can use your editor of choice or GitHub Codespaces. Here are some options we suggest: 8 | - [GitHub Codespaces](https://code.visualstudio.com/docs/remote/codespaces) for an in-browser coding environment 9 | - [Visual Studio Code](https://code.visualstudio.com/), with the [C# Dev Kit Extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) 10 | - [Visual Studio](https://aka.ms/WebLearningSeries-git-vsDownload) - check out our [more detailed instructions](/1-welcome/how-to-install-vs.md) for extra help 11 | - [.NET SDK](https://dot.net/download) 12 | 13 | During the series you will learn the basics of C#, building websites and web APIs, and even how to publish your apps to the cloud. Here is a rundown of what the next few weeks will look like. 14 | 15 | ## Who are we? 16 | Let us introduce ourselves. The content in this series is all written by .NET Developer Community Team from Microsoft. More specifically, Jon, James, Jeff, and Katie will be teaching you web development and all things .NET. 17 | 18 | ## What to expect 19 | - Week 1 – Welcome! 20 | - Week 2 – C# for web development crash course 21 | - Week 3 – We'll build our first pizza website with Razor Pages 🍕 22 | - Week 4 – Upgrade our pizza website with a backend using Minimal web APIs 23 | - Week 5 – Create a Connect 4 Interactive Web Applications with Blazor 24 | - Week 6 – Connect to the cloud by publishing with Azure 25 | 26 | To start you on your journey I want to give you a brief overview of what C# and .NET are, and what tools you will need to get going. 27 | 28 | ## What is .NET? 29 | .NET is a free, cross-platform, open source developer platform for building many different types of applications. This platform is used by companies of all different industries and different sizes. If you’ve ever used Stack Overflow, eaten Chipotle, or received a package delivered by UPS, then you’ve interacted with .NET! 30 | 31 | With .NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, games, IoT, and more! 32 | 33 | ![.NET, a unified development platform](../images/what-is-dotnet.png) 34 | 35 | For this series we’ll use ASP.NET Core and Blazor to build web apps! 36 | -------------------------------------------------------------------------------- /1-welcome/how-to-install-vs.md: -------------------------------------------------------------------------------- 1 | # Install Visual Studio 2 | 3 | If you're using Windows for development, we recommend using Visual Studio for .NET development. Alternatively, you can use Visual Studio Code on Windows, macOS, and Linux. 4 | 5 | ## To set up Visual Studio on Windows 6 | 1. Go to the [Develop .NET applications page](https://visualstudio.microsoft.com/vs/features/net-development/) of the Visual Studio website 7 | 1. Find the "Download Visual Studio with .NET" dropdown and select "Community 2022" 8 | 1. Run the exe and let Visual Studio download 9 | 1. Wait for everything to install 10 | 1. Sign in to Visual Studio 11 | 1. Done ✔️ 12 | 13 | ## To set up Visual Studio Code on Windows, macOS, or Linux 14 | 1. Install the [.NET SDK](https://dot.net/download) 15 | 1. Install [Visual Studio Code](https://code.visualstudio.com) 16 | 1. Install the [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) extension 17 | 1. Done ✔️ 18 | 19 | ## Want more help? 20 | If you want more detailed installation instructions, check out the Microsoft Documentation. 21 | * [Install Visual Studio](https://docs.microsoft.com/visualstudio/install/install-visual-studio?view=vs-2022) 22 | * [Getting Started with C# in VS Code](https://code.visualstudio.com/docs/csharp/get-started) 23 | 24 | Check out the [Learn to code in Visual Studio](https://visualstudio.microsoft.com/vs/getting-started/) page to learn more about the installation process, how to get started with Visual Studio, and how to make it your own with themes! 🤗 25 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/challenge-project/Final/Final.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/challenge-project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Microsoft Learning 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 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/challenge-project/README.md: -------------------------------------------------------------------------------- 1 | # Challenge-project-foreach-if-array-CSharp 2 | Starter and Solution code for the Challenge project: "Develop foreach and if-elseif-else structures to process array data in C#" from the Microsoft Learn collection "Getting started with C#" 3 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/challenge-project/Starter/Program.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This C# console application is designed to: 3 | - Use arrays to store student names and assignment scores. 4 | - Use a `foreach` statement to iterate through the student names as an outer program loop. 5 | - Use an `if` statement within the outer loop to identify the current student name and access that student's assignment scores. 6 | - Use a `foreach` statement within the outer loop to iterate though the assignment scores array and sum the values. 7 | - Use an algorithm within the outer loop to calculate the average exam score for each student. 8 | - Use an `if-elseif-else` construct within the outer loop to evaluate the average exam score and assign a letter grade automatically. 9 | - Integrate extra credit scores when calculating the student's final score and letter grade as follows: 10 | - detects extra credit assignments based on the number of elements in the student's scores array. 11 | - divides the values of extra credit assignments by 10 before adding extra credit scores to the sum of exam scores. 12 | - use the following report format to report student grades: 13 | 14 | Student Grade 15 | 16 | Sophia: 92.2 A- 17 | Andrew: 89.6 B+ 18 | Emma: 85.6 B 19 | Logan: 91.2 A- 20 | */ 21 | int examAssignments = 5; 22 | 23 | string[] studentNames = new string[] { "Sophia", "Andrew", "Emma", "Logan" }; 24 | 25 | int[] sophiaScores = new int[] { 90, 86, 87, 98, 100, 94, 90 }; 26 | int[] andrewScores = new int[] { 92, 89, 81, 96, 90, 89 }; 27 | int[] emmaScores = new int[] { 90, 85, 87, 98, 68, 89, 89, 89 }; 28 | int[] loganScores = new int[] { 90, 95, 87, 88, 96, 96 }; 29 | 30 | int[] studentScores = new int[10]; 31 | 32 | string currentStudentLetterGrade = ""; 33 | 34 | // display the header row for scores/grades 35 | Console.Clear(); 36 | Console.WriteLine("Student\t\tGrade\tLetter Grade\n"); 37 | 38 | /* 39 | The outer foreach loop is used to: 40 | - iterate through student names 41 | - assign a student's grades to the studentScores array 42 | - sum assignment scores (inner foreach loop) 43 | - calculate numeric and letter grade 44 | - write the score report information 45 | */ 46 | foreach (string name in studentNames) 47 | { 48 | string currentStudent = name; 49 | 50 | if (currentStudent == "Sophia") 51 | studentScores = sophiaScores; 52 | 53 | else if (currentStudent == "Andrew") 54 | studentScores = andrewScores; 55 | 56 | else if (currentStudent == "Emma") 57 | studentScores = emmaScores; 58 | 59 | else if (currentStudent == "Logan") 60 | studentScores = loganScores; 61 | 62 | int sumAssignmentScores = 0; 63 | 64 | decimal currentStudentGrade = 0; 65 | 66 | int gradedAssignments = 0; 67 | 68 | /* 69 | the inner foreach loop sums assignment scores 70 | extra credit assignments are worth 10% of an exam score 71 | */ 72 | foreach (int score in studentScores) 73 | { 74 | gradedAssignments += 1; 75 | 76 | if (gradedAssignments <= examAssignments) 77 | sumAssignmentScores += score; 78 | 79 | else 80 | sumAssignmentScores += score / 10; 81 | } 82 | 83 | currentStudentGrade = (decimal)(sumAssignmentScores) / examAssignments; 84 | 85 | if (currentStudentGrade >= 97) 86 | currentStudentLetterGrade = "A+"; 87 | 88 | else if (currentStudentGrade >= 93) 89 | currentStudentLetterGrade = "A"; 90 | 91 | else if (currentStudentGrade >= 90) 92 | currentStudentLetterGrade = "A-"; 93 | 94 | else if (currentStudentGrade >= 87) 95 | currentStudentLetterGrade = "B+"; 96 | 97 | else if (currentStudentGrade >= 83) 98 | currentStudentLetterGrade = "B"; 99 | 100 | else if (currentStudentGrade >= 80) 101 | currentStudentLetterGrade = "B-"; 102 | 103 | else if (currentStudentGrade >= 77) 104 | currentStudentLetterGrade = "C+"; 105 | 106 | else if (currentStudentGrade >= 73) 107 | currentStudentLetterGrade = "C"; 108 | 109 | else if (currentStudentGrade >= 70) 110 | currentStudentLetterGrade = "C-"; 111 | 112 | else if (currentStudentGrade >= 67) 113 | currentStudentLetterGrade = "D+"; 114 | 115 | else if (currentStudentGrade >= 63) 116 | currentStudentLetterGrade = "D"; 117 | 118 | else if (currentStudentGrade >= 60) 119 | currentStudentLetterGrade = "D-"; 120 | 121 | else 122 | currentStudentLetterGrade = "F"; 123 | 124 | // Student Grade 125 | // Sophia: 92.2 A- 126 | 127 | Console.WriteLine($"{currentStudent}\t\t{currentStudentGrade}\t{currentStudentLetterGrade}"); 128 | } 129 | 130 | // required for running in VS Code (keeps the Output windows open to view results) 131 | Console.WriteLine("\n\rPress the Enter key to continue"); 132 | Console.ReadLine(); 133 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/challenge-project/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/guided-project/Final/Final.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/guided-project/Final/Program.cs: -------------------------------------------------------------------------------- 1 | /* 2 | This C# console application is designed to: 3 | - Use arrays to store student names and assignment scores. 4 | - Use a `foreach` statement to iterate through the student names as an outer program loop. 5 | - Use an `if` statement within the outer loop to identify the current student name and access that student's assignment scores. 6 | - Use a `foreach` statement within the outer loop to iterate though the assignment scores array and sum the values. 7 | - Use an algorithm within the outer loop to calculate the average exam score for each student. 8 | - Use an `if-elseif-else` construct within the outer loop to evaluate the average exam score and assign a letter grade automatically. 9 | - Integrate extra credit scores when calculating the student's final score and letter grade as follows: 10 | - detects extra credit assignments based on the number of elements in the student's scores array. 11 | - divides the values of extra credit assignments by 10 before adding extra credit scores to the sum of exam scores. 12 | - use the following report format to report student grades: 13 | 14 | Student Grade 15 | 16 | Sophia: 92.2 A- 17 | Andrew: 89.6 B+ 18 | Emma: 85.6 B 19 | Logan: 91.2 A- 20 | */ 21 | 22 | int examAssignments = 5; 23 | 24 | string[] studentNames = new string[] { "Sophia", "Andrew", "Emma", "Logan" }; 25 | 26 | int[] sophiaScores = new int[] { 90, 86, 87, 98, 100, 94, 90 }; 27 | int[] andrewScores = new int[] { 92, 89, 81, 96, 90, 89 }; 28 | int[] emmaScores = new int[] { 90, 85, 87, 98, 68, 89, 89, 89 }; 29 | int[] loganScores = new int[] { 90, 95, 87, 88, 96, 96 }; 30 | 31 | int[] studentScores = new int[10]; 32 | 33 | string currentStudentLetterGrade = ""; 34 | 35 | // display the header row for scores/grades 36 | Console.Clear(); 37 | Console.WriteLine("Student\t\tGrade\n"); 38 | 39 | /* 40 | The outer foreach loop is used to: 41 | - iterate through student names 42 | - assign a student's grades to the studentScores array 43 | - sum assignment scores (inner foreach loop) 44 | - calculate numeric and letter grade 45 | - write the score report information 46 | */ 47 | foreach (string name in studentNames) 48 | { 49 | string currentStudent = name; 50 | 51 | if (currentStudent == "Sophia") 52 | studentScores = sophiaScores; 53 | 54 | else if (currentStudent == "Andrew") 55 | studentScores = andrewScores; 56 | 57 | else if (currentStudent == "Emma") 58 | studentScores = emmaScores; 59 | 60 | else if (currentStudent == "Logan") 61 | studentScores = loganScores; 62 | 63 | int sumAssignmentScores = 0; 64 | decimal currentStudentGrade = 0; 65 | int gradedAssignments = 0; 66 | 67 | /* 68 | the inner foreach loop sums assignment scores 69 | extra credit assignments are worth 10% of an exam score 70 | */ 71 | foreach (int score in studentScores) 72 | { 73 | gradedAssignments += 1; 74 | 75 | if (gradedAssignments <= examAssignments) 76 | sumAssignmentScores += score; 77 | else 78 | sumAssignmentScores += score / 10; 79 | } 80 | 81 | currentStudentGrade = (decimal)(sumAssignmentScores) / examAssignments; 82 | 83 | if (currentStudentGrade >= 97) 84 | currentStudentLetterGrade = "A+"; 85 | else if (currentStudentGrade >= 93) 86 | currentStudentLetterGrade = "A"; 87 | else if (currentStudentGrade >= 90) 88 | currentStudentLetterGrade = "A-"; 89 | else if (currentStudentGrade >= 87) 90 | currentStudentLetterGrade = "B+"; 91 | else if (currentStudentGrade >= 83) 92 | currentStudentLetterGrade = "B"; 93 | else if (currentStudentGrade >= 80) 94 | currentStudentLetterGrade = "B-"; 95 | else if (currentStudentGrade >= 77) 96 | currentStudentLetterGrade = "C+"; 97 | else if (currentStudentGrade >= 73) 98 | currentStudentLetterGrade = "C"; 99 | else if (currentStudentGrade >= 70) 100 | currentStudentLetterGrade = "C-"; 101 | else if (currentStudentGrade >= 67) 102 | currentStudentLetterGrade = "D+"; 103 | else if (currentStudentGrade >= 63) 104 | currentStudentLetterGrade = "D"; 105 | else if (currentStudentGrade >= 60) 106 | currentStudentLetterGrade = "D-"; 107 | else 108 | currentStudentLetterGrade = "F"; 109 | 110 | // Student Grade 111 | // Sophia: 92.2 A- 112 | 113 | Console.WriteLine($"{currentStudent}\t\t{currentStudentGrade}\t{currentStudentLetterGrade}"); 114 | } 115 | 116 | // required for running in VS Code (keeps the Output windows open to view results) 117 | Console.WriteLine("\n\rPress the Enter key to continue"); 118 | Console.ReadLine(); 119 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/guided-project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Microsoft Learning 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 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/guided-project/README.md: -------------------------------------------------------------------------------- 1 | # Guided-project-foreach-if-array-CSharp 2 | Starter and Solution code for the Guided project: "Develop foreach and if-elseif-else structures to process array data in C#" from the Microsoft Learn collection "Getting started with C#" 3 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/guided-project/Starter/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | // initialize variables - graded assignments 4 | int currentAssignments = 5; 5 | 6 | int sophia1 = 90; 7 | int sophia2 = 86; 8 | int sophia3 = 87; 9 | int sophia4 = 98; 10 | int sophia5 = 100; 11 | 12 | int andrew1 = 92; 13 | int andrew2 = 89; 14 | int andrew3 = 81; 15 | int andrew4 = 96; 16 | int andrew5 = 90; 17 | 18 | int emma1 = 90; 19 | int emma2 = 85; 20 | int emma3 = 87; 21 | int emma4 = 98; 22 | int emma5 = 68; 23 | 24 | int logan1 = 90; 25 | int logan2 = 95; 26 | int logan3 = 87; 27 | int logan4 = 88; 28 | int logan5 = 96; 29 | 30 | int sophiaSum = 0; 31 | int andrewSum = 0; 32 | int emmaSum = 0; 33 | int loganSum = 0; 34 | 35 | decimal sophiaScore; 36 | decimal andrewScore; 37 | decimal emmaScore; 38 | decimal loganScore; 39 | 40 | sophiaSum = sophia1 + sophia2 + sophia3 + sophia4 + sophia5; 41 | andrewSum = andrew1 + andrew2 + andrew3 + andrew4 + andrew5; 42 | emmaSum = emma1 + emma2 + emma3 + emma4 + emma5; 43 | loganSum = logan1 + logan2 + logan3 + logan4 + logan5; 44 | 45 | sophiaScore = (decimal)sophiaSum / currentAssignments; 46 | andrewScore = (decimal)andrewSum / currentAssignments; 47 | emmaScore = (decimal)emmaSum / currentAssignments; 48 | loganScore = (decimal)loganSum / currentAssignments; 49 | 50 | Console.WriteLine("Student\t\tGrade\n"); 51 | Console.WriteLine("Sophia:\t\t" + sophiaScore + "\tA-"); 52 | Console.WriteLine("Andrew:\t\t" + andrewScore + "\tB+"); 53 | Console.WriteLine("Emma:\t\t" + emmaScore + "\tB"); 54 | Console.WriteLine("Logan:\t\t" + loganScore + "\tA-"); 55 | 56 | Console.WriteLine("Press the Enter key to continue"); 57 | Console.ReadLine(); 58 | -------------------------------------------------------------------------------- /2-csharp/lesson-2-projects/guided-project/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-3-projects/challenge-project/Final/Final.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-3-projects/challenge-project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Microsoft Learning 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 | -------------------------------------------------------------------------------- /2-csharp/lesson-3-projects/challenge-project/README.md: -------------------------------------------------------------------------------- 1 | # Challenge-project-branching-looping-CSharp 2 | Starter and Solution code for the Challenge project: "Develop conditional branching and looping structures in C#" from the Microsoft Learn collection "Getting started with C#" 3 | -------------------------------------------------------------------------------- /2-csharp/lesson-3-projects/challenge-project/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-3-projects/guided-project/Final/Final.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-3-projects/guided-project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Microsoft Learning 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 | -------------------------------------------------------------------------------- /2-csharp/lesson-3-projects/guided-project/README.md: -------------------------------------------------------------------------------- 1 | # Guided-project-branching-looping-CSharp 2 | Starter and Solution code for the Guided project: "Develop conditional branching and looping structures in C#" from the Microsoft Learn collection "Getting started with C#" 3 | -------------------------------------------------------------------------------- /2-csharp/lesson-3-projects/guided-project/Starter/Program.cs: -------------------------------------------------------------------------------- 1 | // the ourAnimals array will store the following: 2 | string animalSpecies = ""; 3 | string animalID = ""; 4 | string animalAge = ""; 5 | string animalPhysicalDescription = ""; 6 | string animalPersonalityDescription = ""; 7 | string animalNickname = ""; 8 | 9 | // variables that support data entry 10 | int maxPets = 8; 11 | string? readResult; 12 | string menuSelection = ""; 13 | 14 | // array used to store runtime data, there is no persisted data 15 | string[,] ourAnimals = new string[maxPets, 6]; 16 | 17 | // TODO: Convert the if-elseif-else construct to a switch statement 18 | 19 | // create some initial ourAnimals array entries 20 | for (int i = 0; i < maxPets; i++) 21 | { 22 | if (i == 0) 23 | { 24 | animalSpecies = "dog"; 25 | animalID = "d1"; 26 | animalAge = "2"; 27 | animalPhysicalDescription = "medium sized cream colored female golden retriever weighing about 65 pounds. housebroken."; 28 | animalPersonalityDescription = "loves to have her belly rubbed and likes to chase her tail. gives lots of kisses."; 29 | animalNickname = "lola"; 30 | } 31 | else if (i == 1) 32 | { 33 | animalSpecies = "dog"; 34 | animalID = "d2"; 35 | animalAge = "9"; 36 | animalPhysicalDescription = "large reddish-brown male golden retriever weighing about 85 pounds. housebroken."; 37 | animalPersonalityDescription = "loves to have his ears rubbed when he greets you at the door, or at any time! loves to lean-in and give doggy hugs."; 38 | animalNickname = "loki"; 39 | } 40 | else if (i == 2) 41 | { 42 | animalSpecies = "cat"; 43 | animalID = "c3"; 44 | animalAge = "1"; 45 | animalPhysicalDescription = "small white female weighing about 8 pounds. litter box trained."; 46 | animalPersonalityDescription = "friendly"; 47 | animalNickname = "Puss"; 48 | } 49 | else if (i == 3) 50 | { 51 | animalSpecies = "cat"; 52 | animalID = "c4"; 53 | animalAge = "?"; 54 | animalPhysicalDescription = ""; 55 | animalPersonalityDescription = ""; 56 | animalNickname = ""; 57 | } 58 | else 59 | { 60 | animalSpecies = ""; 61 | animalID = ""; 62 | animalAge = ""; 63 | animalPhysicalDescription = ""; 64 | animalPersonalityDescription = ""; 65 | animalNickname = ""; 66 | } 67 | 68 | ourAnimals[i, 0] = "ID #: " + animalID; 69 | ourAnimals[i, 1] = "Species: " + animalSpecies; 70 | ourAnimals[i, 2] = "Age: " + animalAge; 71 | ourAnimals[i, 3] = "Nickname: " + animalNickname; 72 | ourAnimals[i, 4] = "Physical description: " + animalPhysicalDescription; 73 | ourAnimals[i, 5] = "Personality: " + animalPersonalityDescription; 74 | } 75 | 76 | // display the top-level menu options 77 | 78 | Console.Clear(); 79 | 80 | Console.WriteLine("Welcome to the Contoso PetFriends app. Your main menu options are:"); 81 | Console.WriteLine(" 1. List all of our current pet information"); 82 | Console.WriteLine(" 2. Add a new animal friend to the ourAnimals array"); 83 | Console.WriteLine(" 3. Ensure animal ages and physical descriptions are complete"); 84 | Console.WriteLine(" 4. Ensure animal nicknames and personality descriptions are complete"); 85 | Console.WriteLine(" 5. Edit an animal’s age"); 86 | Console.WriteLine(" 6. Edit an animal’s personality description"); 87 | Console.WriteLine(" 7. Display all cats with a specified characteristic"); 88 | Console.WriteLine(" 8. Display all dogs with a specified characteristic"); 89 | Console.WriteLine(); 90 | Console.WriteLine("Enter your selection number (or type Exit to exit the program)"); 91 | 92 | readResult = Console.ReadLine(); 93 | if (readResult != null) 94 | { 95 | menuSelection = readResult.ToLower(); 96 | } 97 | 98 | Console.WriteLine($"You selected menu option {menuSelection}."); 99 | Console.WriteLine("Press the Enter key to continue"); 100 | 101 | // pause code execution 102 | readResult = Console.ReadLine(); 103 | -------------------------------------------------------------------------------- /2-csharp/lesson-3-projects/guided-project/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-4-projects/challenge-project/Final/Final.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-4-projects/challenge-project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Microsoft Learning 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 | -------------------------------------------------------------------------------- /2-csharp/lesson-4-projects/challenge-project/README.md: -------------------------------------------------------------------------------- 1 | # Challenge-project-Work-with-variable-data-in-CSharp 2 | Starter and Solution code for the **Challenge project**: "Work with variable data in C# console applications" from the Microsoft Learn collection "Getting started with C#" 3 | -------------------------------------------------------------------------------- /2-csharp/lesson-4-projects/challenge-project/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-4-projects/guided-project/Final/Final.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-4-projects/guided-project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Microsoft Learning 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 | -------------------------------------------------------------------------------- /2-csharp/lesson-4-projects/guided-project/README.md: -------------------------------------------------------------------------------- 1 | # Guided-project-Work-with-variable-data-in-CSharp 2 | 3 | Starter and Solution code for the **Guided project**: "Work with variable data in C# console applications" from the Microsoft Learn collection "Getting started with C#" 4 | -------------------------------------------------------------------------------- /2-csharp/lesson-4-projects/guided-project/Starter/Program.cs: -------------------------------------------------------------------------------- 1 | // #1 the ourAnimals array will store the following: 2 | string animalSpecies = ""; 3 | string animalID = ""; 4 | string animalAge = ""; 5 | string animalPhysicalDescription = ""; 6 | string animalPersonalityDescription = ""; 7 | string animalNickname = ""; 8 | 9 | // #2 variables that support data entry 10 | int maxPets = 8; 11 | string? readResult; 12 | string menuSelection = ""; 13 | 14 | // #3 array used to store runtime data, there is no persisted data 15 | string[,] ourAnimals = new string[maxPets, 6]; 16 | 17 | // #4 create sample data ourAnimals array entries 18 | for (int i = 0; i < maxPets; i++) 19 | { 20 | switch (i) 21 | { 22 | case 0: 23 | animalSpecies = "dog"; 24 | animalID = "d1"; 25 | animalAge = "2"; 26 | animalPhysicalDescription = "medium sized cream colored female golden retriever weighing about 45 pounds. housebroken."; 27 | animalPersonalityDescription = "loves to have her belly rubbed and likes to chase her tail. gives lots of kisses."; 28 | animalNickname = "lola"; 29 | break; 30 | 31 | case 1: 32 | animalSpecies = "dog"; 33 | animalID = "d2"; 34 | animalAge = "9"; 35 | animalPhysicalDescription = "large reddish-brown male golden retriever weighing about 85 pounds. housebroken."; 36 | animalPersonalityDescription = "loves to have his ears rubbed when he greets you at the door, or at any time! loves to lean-in and give doggy hugs."; 37 | animalNickname = "gus"; 38 | break; 39 | 40 | case 2: 41 | animalSpecies = "cat"; 42 | animalID = "c3"; 43 | animalAge = "1"; 44 | animalPhysicalDescription = "small white female weighing about 8 pounds. litter box trained."; 45 | animalPersonalityDescription = "friendly"; 46 | animalNickname = "snow"; 47 | break; 48 | 49 | case 3: 50 | animalSpecies = "cat"; 51 | animalID = "c4"; 52 | animalAge = "3"; 53 | animalPhysicalDescription = "Medium sized, long hair, yellow, female, about 10 pounds. Uses litter box."; 54 | animalPersonalityDescription = "A people loving cat that likes to sit on your lap."; 55 | animalNickname = "Lion"; 56 | break; 57 | 58 | default: 59 | animalSpecies = ""; 60 | animalID = ""; 61 | animalAge = ""; 62 | animalPhysicalDescription = ""; 63 | animalPersonalityDescription = ""; 64 | animalNickname = ""; 65 | break; 66 | 67 | } 68 | 69 | ourAnimals[i, 0] = "ID #: " + animalID; 70 | ourAnimals[i, 1] = "Species: " + animalSpecies; 71 | ourAnimals[i, 2] = "Age: " + animalAge; 72 | ourAnimals[i, 3] = "Nickname: " + animalNickname; 73 | ourAnimals[i, 4] = "Physical description: " + animalPhysicalDescription; 74 | ourAnimals[i, 5] = "Personality: " + animalPersonalityDescription; 75 | 76 | } 77 | 78 | // #5 display the top-level menu options 79 | do 80 | { 81 | // NOTE: the Console.Clear method is throwing an exception in debug sessions 82 | Console.Clear(); 83 | 84 | Console.WriteLine("Welcome to the Contoso PetFriends app. Your main menu options are:"); 85 | Console.WriteLine(" 1. List all of our current pet information"); 86 | Console.WriteLine(" 2. Display all dogs with a specified characteristic"); 87 | Console.WriteLine(); 88 | Console.WriteLine("Enter your selection number (or type Exit to exit the program)"); 89 | 90 | readResult = Console.ReadLine(); 91 | if (readResult != null) 92 | { 93 | menuSelection = readResult.ToLower(); 94 | } 95 | 96 | // use switch-case to process the selected menu option 97 | switch (menuSelection) 98 | { 99 | case "1": 100 | // list all pet info 101 | for (int i = 0; i < maxPets; i++) 102 | { 103 | if (ourAnimals[i, 0] != "ID #: ") 104 | { 105 | Console.WriteLine(); 106 | for (int j = 0; j < 6; j++) 107 | { 108 | Console.WriteLine(ourAnimals[i, j]); 109 | } 110 | } 111 | } 112 | Console.WriteLine("\n\rPress the Enter key to continue"); 113 | readResult = Console.ReadLine(); 114 | 115 | break; 116 | 117 | case "2": 118 | // Display all dogs with a specified characteristic 119 | Console.WriteLine("\nUNDER CONSTRUCTION - please check back next month to see progress."); 120 | Console.WriteLine("Press the Enter key to continue."); 121 | readResult = Console.ReadLine(); 122 | break; 123 | 124 | default: 125 | break; 126 | } 127 | 128 | } while (menuSelection != "exit"); 129 | -------------------------------------------------------------------------------- /2-csharp/lesson-4-projects/guided-project/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-5-projects/challenge-project/Final/Final.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-5-projects/challenge-project/Final/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | Random random = new Random(); 4 | Console.CursorVisible = false; 5 | int height = Console.WindowHeight - 1; 6 | int width = Console.WindowWidth - 5; 7 | bool shouldExit = false; 8 | 9 | // Console position of the player 10 | int playerX = 0; 11 | int playerY = 0; 12 | 13 | // Console position of the food 14 | int foodX = 0; 15 | int foodY = 0; 16 | 17 | // Available player and food strings 18 | string[] states = {"('-')", "(^-^)", "(X_X)"}; 19 | string[] foods = {"@@@@@", "$$$$$", "#####"}; 20 | 21 | // Current player string displayed in the Console 22 | string player = states[0]; 23 | 24 | // Index of the current food 25 | int food = 0; 26 | 27 | InitializeGame(); 28 | while (!shouldExit) 29 | { 30 | if (TerminalResized()) 31 | { 32 | Console.Clear(); 33 | Console.Write("Console was resized. Program exiting."); 34 | shouldExit = true; 35 | } 36 | else 37 | { 38 | if (PlayerIsFaster()) 39 | { 40 | Move(1, false); 41 | } 42 | else if (PlayerIsSick()) 43 | { 44 | FreezePlayer(); 45 | } else 46 | { 47 | Move(otherKeysExit: false); 48 | } 49 | if (GotFood()) 50 | { 51 | ChangePlayer(); 52 | ShowFood(); 53 | } 54 | } 55 | } 56 | 57 | // Returns true if the Terminal was resized 58 | bool TerminalResized() 59 | { 60 | return height != Console.WindowHeight - 1 || width != Console.WindowWidth - 5; 61 | } 62 | 63 | // Displays random food at a random location 64 | void ShowFood() 65 | { 66 | // Update food to a random index 67 | food = random.Next(0, foods.Length); 68 | 69 | // Update food position to a random location 70 | foodX = random.Next(0, width - player.Length); 71 | foodY = random.Next(0, height - 1); 72 | 73 | // Display the food at the location 74 | Console.SetCursorPosition(foodX, foodY); 75 | Console.Write(foods[food]); 76 | } 77 | 78 | // Returns true if the player location matches the food location 79 | bool GotFood() 80 | { 81 | return playerY == foodY && playerX == foodX; 82 | } 83 | 84 | // Returns true if the player appearance represents a sick state 85 | bool PlayerIsSick() 86 | { 87 | return player.Equals(states[2]); 88 | } 89 | 90 | // Returns true if the player appearance represents a fast state 91 | bool PlayerIsFaster() 92 | { 93 | return player.Equals(states[1]); 94 | } 95 | 96 | // Changes the player to match the food consumed 97 | void ChangePlayer() 98 | { 99 | player = states[food]; 100 | Console.SetCursorPosition(playerX, playerY); 101 | Console.Write(player); 102 | } 103 | 104 | // Temporarily stops the player from moving 105 | void FreezePlayer() 106 | { 107 | System.Threading.Thread.Sleep(1000); 108 | player = states[0]; 109 | } 110 | 111 | // Reads directional input from the Console and moves the player 112 | void Move(int speed = 1, bool otherKeysExit = false) 113 | { 114 | int lastX = playerX; 115 | int lastY = playerY; 116 | 117 | switch (Console.ReadKey(true).Key) { 118 | case ConsoleKey.UpArrow: 119 | playerY--; 120 | break; 121 | case ConsoleKey.DownArrow: 122 | playerY++; 123 | break; 124 | case ConsoleKey.LeftArrow: 125 | playerX -= speed; 126 | break; 127 | case ConsoleKey.RightArrow: 128 | playerX += speed; 129 | break; 130 | case ConsoleKey.Escape: 131 | shouldExit = true; 132 | break; 133 | default: 134 | // Exit if any other keys are pressed 135 | shouldExit = otherKeysExit; 136 | break; 137 | } 138 | 139 | // Clear the characters at the previous position 140 | Console.SetCursorPosition(lastX, lastY); 141 | for (int i = 0; i < player.Length; i++) 142 | { 143 | Console.Write(" "); 144 | } 145 | 146 | // Keep player position within the bounds of the Terminal window 147 | playerX = (playerX < 0) ? 0 : (playerX >= width ? width : playerX); 148 | playerY = (playerY < 0) ? 0 : (playerY >= height ? height : playerY); 149 | 150 | // Draw the player at the new location 151 | Console.SetCursorPosition(playerX, playerY); 152 | Console.Write(player); 153 | } 154 | 155 | // Clears the console, displays the food and player 156 | void InitializeGame() 157 | { 158 | Console.Clear(); 159 | ShowFood(); 160 | Console.SetCursorPosition(0, 0); 161 | Console.Write(player); 162 | } -------------------------------------------------------------------------------- /2-csharp/lesson-5-projects/challenge-project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Microsoft Learning 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 | -------------------------------------------------------------------------------- /2-csharp/lesson-5-projects/challenge-project/README.md: -------------------------------------------------------------------------------- 1 | # Challenge-project-Create-methods-in-CSharp 2 | 3 | Starter and Final code for the Challenge project: "Create methods C# console applications" from the Microsoft Learn collection "Getting started with C#" 4 | -------------------------------------------------------------------------------- /2-csharp/lesson-5-projects/challenge-project/Starter/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | Random random = new Random(); 4 | Console.CursorVisible = false; 5 | int height = Console.WindowHeight - 1; 6 | int width = Console.WindowWidth - 5; 7 | bool shouldExit = false; 8 | 9 | // Console position of the player 10 | int playerX = 0; 11 | int playerY = 0; 12 | 13 | // Console position of the food 14 | int foodX = 0; 15 | int foodY = 0; 16 | 17 | // Available player and food strings 18 | string[] states = {"('-')", "(^-^)", "(X_X)"}; 19 | string[] foods = {"@@@@@", "$$$$$", "#####"}; 20 | 21 | // Current player string displayed in the Console 22 | string player = states[0]; 23 | 24 | // Index of the current food 25 | int food = 0; 26 | 27 | InitializeGame(); 28 | while (!shouldExit) 29 | { 30 | Move(); 31 | } 32 | 33 | // Returns true if the Terminal was resized 34 | bool TerminalResized() 35 | { 36 | return height != Console.WindowHeight - 1 || width != Console.WindowWidth - 5; 37 | } 38 | 39 | // Displays random food at a random location 40 | void ShowFood() 41 | { 42 | // Update food to a random index 43 | food = random.Next(0, foods.Length); 44 | 45 | // Update food position to a random location 46 | foodX = random.Next(0, width - player.Length); 47 | foodY = random.Next(0, height - 1); 48 | 49 | // Display the food at the location 50 | Console.SetCursorPosition(foodX, foodY); 51 | Console.Write(foods[food]); 52 | } 53 | 54 | // Changes the player to match the food consumed 55 | void ChangePlayer() 56 | { 57 | player = states[food]; 58 | Console.SetCursorPosition(playerX, playerY); 59 | Console.Write(player); 60 | } 61 | 62 | // Temporarily stops the player from moving 63 | void FreezePlayer() 64 | { 65 | System.Threading.Thread.Sleep(1000); 66 | player = states[0]; 67 | } 68 | 69 | // Reads directional input from the Console and moves the player 70 | void Move() 71 | { 72 | int lastX = playerX; 73 | int lastY = playerY; 74 | 75 | switch (Console.ReadKey(true).Key) 76 | { 77 | case ConsoleKey.UpArrow: 78 | playerY--; 79 | break; 80 | case ConsoleKey.DownArrow: 81 | playerY++; 82 | break; 83 | case ConsoleKey.LeftArrow: 84 | playerX--; 85 | break; 86 | case ConsoleKey.RightArrow: 87 | playerX++; 88 | break; 89 | case ConsoleKey.Escape: 90 | shouldExit = true; 91 | break; 92 | } 93 | 94 | // Clear the characters at the previous position 95 | Console.SetCursorPosition(lastX, lastY); 96 | for (int i = 0; i < player.Length; i++) 97 | { 98 | Console.Write(" "); 99 | } 100 | 101 | // Keep player position within the bounds of the Terminal window 102 | playerX = (playerX < 0) ? 0 : (playerX >= width ? width : playerX); 103 | playerY = (playerY < 0) ? 0 : (playerY >= height ? height : playerY); 104 | 105 | // Draw the player at the new location 106 | Console.SetCursorPosition(playerX, playerY); 107 | Console.Write(player); 108 | } 109 | 110 | // Clears the console, displays the food and player 111 | void InitializeGame() 112 | { 113 | Console.Clear(); 114 | ShowFood(); 115 | Console.SetCursorPosition(0, 0); 116 | Console.Write(player); 117 | } -------------------------------------------------------------------------------- /2-csharp/lesson-5-projects/challenge-project/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-6-projects/challenge-project/Final/Final.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-6-projects/challenge-project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Microsoft Learning 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 | -------------------------------------------------------------------------------- /2-csharp/lesson-6-projects/challenge-project/README.md: -------------------------------------------------------------------------------- 1 | # Challenge-project-debugging-CSharp 2 | Starter and Solution code for the Challenge project: "Debug a C# console application using Visual Studio Code" from the Microsoft Learn collection "Getting started with C#" 3 | -------------------------------------------------------------------------------- /2-csharp/lesson-6-projects/challenge-project/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-6-projects/guided-project/Final/Final.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /2-csharp/lesson-6-projects/guided-project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Microsoft Learning 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 | -------------------------------------------------------------------------------- /2-csharp/lesson-6-projects/guided-project/README.md: -------------------------------------------------------------------------------- 1 | # Guided-project-debugging-CSharp 2 | Starter and Solution code for the Guided project: "Debug and handle exceptions in a C# console application using Visual Studio Code" from the Microsoft Learn collection "Getting started with C#" 3 | -------------------------------------------------------------------------------- /2-csharp/lesson-6-projects/guided-project/Starter/Starter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.33808.371 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RazorPagesPizza", "RazorPagesPizza\RazorPagesPizza.csproj", "{ADA085D1-1380-4955-A58D-FD688EC5B4B9}" 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 | {ADA085D1-1380-4955-A58D-FD688EC5B4B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {ADA085D1-1380-4955-A58D-FD688EC5B4B9}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {ADA085D1-1380-4955-A58D-FD688EC5B4B9}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {ADA085D1-1380-4955-A58D-FD688EC5B4B9}.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 = {7052E9F1-F97B-4A22-AEA8-66D01D921E93} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace RazorPagesPizza.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 | } -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/Pages/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesPizza.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 | } -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/Pages/Privacy.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesPizza.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 | } -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - RazorPagesPizza 7 | 8 | 9 | 10 | 11 | 12 |
13 | 32 |
33 |
34 |
35 | @RenderBody() 36 |
37 |
38 | 39 |
40 |
41 | © 2023 - RazorPagesPizza - Privacy 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | @await RenderSectionAsync("Scripts", required: false) 50 | 51 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using RazorPagesPizza 2 | @namespace RazorPagesPizza.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:56089", 7 | "sslPort": 44328 8 | } 9 | }, 10 | "profiles": { 11 | "http": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "http://localhost:5101", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "https": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": true, 23 | "launchBrowser": true, 24 | "applicationUrl": "https://localhost:7001;http://localhost:5101", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | }, 29 | "IIS Express": { 30 | "commandName": "IISExpress", 31 | "launchBrowser": true, 32 | "environmentVariables": { 33 | "ASPNETCORE_ENVIRONMENT": "Development" 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/RazorPagesPizza.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | } -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/wwwroot/favicon.ico -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v5.1.0 (https://getbootstrap.com/) 3 | * Copyright 2011-2021 The Bootstrap Authors 4 | * Copyright 2011-2021 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v5.1.0 (https://getbootstrap.com/) 3 | * Copyright 2011-2021 The Bootstrap Authors 4 | * Copyright 2011-2021 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-right:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-right:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:right}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:right;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:right}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}[type=email],[type=number],[type=tel],[type=url]{direction:ltr}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.rtl.min.css.map */ -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/0-start/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.33808.371 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RazorPagesPizza", "RazorPagesPizza\RazorPagesPizza.csproj", "{ADA085D1-1380-4955-A58D-FD688EC5B4B9}" 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 | {ADA085D1-1380-4955-A58D-FD688EC5B4B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {ADA085D1-1380-4955-A58D-FD688EC5B4B9}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {ADA085D1-1380-4955-A58D-FD688EC5B4B9}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {ADA085D1-1380-4955-A58D-FD688EC5B4B9}.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 = {7052E9F1-F97B-4A22-AEA8-66D01D921E93} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Data/RazorPagesPizzaContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using RazorPagesPizza.Models; 7 | 8 | namespace RazorPagesPizza.Data 9 | { 10 | public class RazorPagesPizzaContext : DbContext 11 | { 12 | public RazorPagesPizzaContext (DbContextOptions options) 13 | : base(options) 14 | { 15 | } 16 | 17 | public DbSet Pizza { get; set; } = default!; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Migrations/20230630173639_InitialCreate.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 7 | using RazorPagesPizza.Data; 8 | 9 | #nullable disable 10 | 11 | namespace RazorPagesPizza.Migrations 12 | { 13 | [DbContext(typeof(RazorPagesPizzaContext))] 14 | [Migration("20230630173639_InitialCreate")] 15 | partial class InitialCreate 16 | { 17 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 18 | { 19 | #pragma warning disable 612, 618 20 | modelBuilder 21 | .HasAnnotation("ProductVersion", "6.0.18") 22 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 23 | 24 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); 25 | 26 | modelBuilder.Entity("RazorPagesPizza.Models.Pizza", b => 27 | { 28 | b.Property("Id") 29 | .ValueGeneratedOnAdd() 30 | .HasColumnType("int"); 31 | 32 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); 33 | 34 | b.Property("IsGlutenFree") 35 | .HasColumnType("bit"); 36 | 37 | b.Property("Name") 38 | .IsRequired() 39 | .HasColumnType("nvarchar(max)"); 40 | 41 | b.Property("Price") 42 | .HasColumnType("decimal(18,2)"); 43 | 44 | b.HasKey("Id"); 45 | 46 | b.ToTable("Pizza"); 47 | }); 48 | #pragma warning restore 612, 618 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Migrations/20230630173639_InitialCreate.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | #nullable disable 4 | 5 | namespace RazorPagesPizza.Migrations 6 | { 7 | public partial class InitialCreate : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.CreateTable( 12 | name: "Pizza", 13 | columns: table => new 14 | { 15 | Id = table.Column(type: "int", nullable: false) 16 | .Annotation("SqlServer:Identity", "1, 1"), 17 | Name = table.Column(type: "nvarchar(max)", nullable: false), 18 | IsGlutenFree = table.Column(type: "bit", nullable: false), 19 | Price = table.Column(type: "decimal(18,2)", nullable: false) 20 | }, 21 | constraints: table => 22 | { 23 | table.PrimaryKey("PK_Pizza", x => x.Id); 24 | }); 25 | } 26 | 27 | protected override void Down(MigrationBuilder migrationBuilder) 28 | { 29 | migrationBuilder.DropTable( 30 | name: "Pizza"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Migrations/RazorPagesPizzaContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 6 | using RazorPagesPizza.Data; 7 | 8 | #nullable disable 9 | 10 | namespace RazorPagesPizza.Migrations 11 | { 12 | [DbContext(typeof(RazorPagesPizzaContext))] 13 | partial class RazorPagesPizzaContextModelSnapshot : ModelSnapshot 14 | { 15 | protected override void BuildModel(ModelBuilder modelBuilder) 16 | { 17 | #pragma warning disable 612, 618 18 | modelBuilder 19 | .HasAnnotation("ProductVersion", "6.0.18") 20 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 21 | 22 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); 23 | 24 | modelBuilder.Entity("RazorPagesPizza.Models.Pizza", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("int"); 29 | 30 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); 31 | 32 | b.Property("IsGlutenFree") 33 | .HasColumnType("bit"); 34 | 35 | b.Property("Name") 36 | .IsRequired() 37 | .HasColumnType("nvarchar(max)"); 38 | 39 | b.Property("Price") 40 | .HasColumnType("decimal(18,2)"); 41 | 42 | b.HasKey("Id"); 43 | 44 | b.ToTable("Pizza"); 45 | }); 46 | #pragma warning restore 612, 618 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Models/Pizza.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace RazorPagesPizza.Models; 4 | 5 | public class Pizza 6 | { 7 | public int Id { get; set; } 8 | 9 | [Required] 10 | public string? Name { get; set; } 11 | public bool IsGlutenFree { get; set; } 12 | 13 | [Range(0.01, 9999.99)] 14 | public decimal Price { get; set; } 15 | } -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/Create.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesPizza.Pages.CreateModel 3 | 4 | @{ 5 | ViewData["Title"] = "Create"; 6 | } 7 | 8 |

Create

9 | 10 |

Pizza

11 |
12 |
13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 |
21 |
22 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 |
34 |
35 |
36 |
37 | 38 |
39 | Back to List 40 |
41 | 42 | @section Scripts { 43 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 44 | } 45 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/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 RazorPagesPizza.Data; 9 | using RazorPagesPizza.Models; 10 | 11 | namespace RazorPagesPizza.Pages 12 | { 13 | public class CreateModel : PageModel 14 | { 15 | private readonly RazorPagesPizza.Data.RazorPagesPizzaContext _context; 16 | 17 | public CreateModel(RazorPagesPizza.Data.RazorPagesPizzaContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public IActionResult OnGet() 23 | { 24 | return Page(); 25 | } 26 | 27 | [BindProperty] 28 | public Pizza Pizza { 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.Pizza == null || Pizza == null) 35 | { 36 | return Page(); 37 | } 38 | 39 | _context.Pizza.Add(Pizza); 40 | await _context.SaveChangesAsync(); 41 | 42 | return RedirectToPage("./Index"); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesPizza.Pages.DeleteModel 3 | 4 | @{ 5 | ViewData["Title"] = "Delete"; 6 | } 7 | 8 |

Delete

9 | 10 |

Are you sure you want to delete this?

11 |
12 |

Pizza

13 |
14 |
15 |
16 | @Html.DisplayNameFor(model => model.Pizza.Name) 17 |
18 |
19 | @Html.DisplayFor(model => model.Pizza.Name) 20 |
21 |
22 | @Html.DisplayNameFor(model => model.Pizza.IsGlutenFree) 23 |
24 |
25 | @Html.DisplayFor(model => model.Pizza.IsGlutenFree) 26 |
27 |
28 | @Html.DisplayNameFor(model => model.Pizza.Price) 29 |
30 |
31 | @Html.DisplayFor(model => model.Pizza.Price) 32 |
33 |
34 | 35 |
36 | 37 | | 38 | Back to List 39 |
40 |
41 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/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 RazorPagesPizza.Data; 9 | using RazorPagesPizza.Models; 10 | 11 | namespace RazorPagesPizza.Pages 12 | { 13 | public class DeleteModel : PageModel 14 | { 15 | private readonly RazorPagesPizza.Data.RazorPagesPizzaContext _context; 16 | 17 | public DeleteModel(RazorPagesPizza.Data.RazorPagesPizzaContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | [BindProperty] 23 | public Pizza Pizza { get; set; } = default!; 24 | 25 | public async Task OnGetAsync(int? id) 26 | { 27 | if (id == null || _context.Pizza == null) 28 | { 29 | return NotFound(); 30 | } 31 | 32 | var pizza = await _context.Pizza.FirstOrDefaultAsync(m => m.Id == id); 33 | 34 | if (pizza == null) 35 | { 36 | return NotFound(); 37 | } 38 | else 39 | { 40 | Pizza = pizza; 41 | } 42 | return Page(); 43 | } 44 | 45 | public async Task OnPostAsync(int? id) 46 | { 47 | if (id == null || _context.Pizza == null) 48 | { 49 | return NotFound(); 50 | } 51 | var pizza = await _context.Pizza.FindAsync(id); 52 | 53 | if (pizza != null) 54 | { 55 | Pizza = pizza; 56 | _context.Pizza.Remove(Pizza); 57 | await _context.SaveChangesAsync(); 58 | } 59 | 60 | return RedirectToPage("./Index"); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/Details.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesPizza.Pages.DetailsModel 3 | 4 | @{ 5 | ViewData["Title"] = "Details"; 6 | } 7 | 8 |

Details

9 | 10 |
11 |

Pizza

12 |
13 |
14 |
15 | @Html.DisplayNameFor(model => model.Pizza.Name) 16 |
17 |
18 | @Html.DisplayFor(model => model.Pizza.Name) 19 |
20 |
21 | @Html.DisplayNameFor(model => model.Pizza.IsGlutenFree) 22 |
23 |
24 | @Html.DisplayFor(model => model.Pizza.IsGlutenFree) 25 |
26 |
27 | @Html.DisplayNameFor(model => model.Pizza.Price) 28 |
29 |
30 | @Html.DisplayFor(model => model.Pizza.Price) 31 |
32 |
33 |
34 |
35 | Edit | 36 | Back to List 37 |
38 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/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 RazorPagesPizza.Data; 9 | using RazorPagesPizza.Models; 10 | 11 | namespace RazorPagesPizza.Pages 12 | { 13 | public class DetailsModel : PageModel 14 | { 15 | private readonly RazorPagesPizza.Data.RazorPagesPizzaContext _context; 16 | 17 | public DetailsModel(RazorPagesPizza.Data.RazorPagesPizzaContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public Pizza Pizza { get; set; } = default!; 23 | 24 | public async Task OnGetAsync(int? id) 25 | { 26 | if (id == null || _context.Pizza == null) 27 | { 28 | return NotFound(); 29 | } 30 | 31 | var pizza = await _context.Pizza.FirstOrDefaultAsync(m => m.Id == id); 32 | if (pizza == null) 33 | { 34 | return NotFound(); 35 | } 36 | else 37 | { 38 | Pizza = pizza; 39 | } 40 | return Page(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesPizza.Pages.EditModel 3 | 4 | @{ 5 | ViewData["Title"] = "Edit"; 6 | } 7 | 8 |

Edit

9 | 10 |

Pizza

11 |
12 |
13 |
14 |
15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 |
23 | 26 |
27 |
28 | 29 | 30 | 31 |
32 |
33 | 34 |
35 |
36 |
37 |
38 | 39 |
40 | Back to List 41 |
42 | 43 | @section Scripts { 44 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 45 | } 46 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/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 RazorPagesPizza.Data; 10 | using RazorPagesPizza.Models; 11 | 12 | namespace RazorPagesPizza.Pages 13 | { 14 | public class EditModel : PageModel 15 | { 16 | private readonly RazorPagesPizza.Data.RazorPagesPizzaContext _context; 17 | 18 | public EditModel(RazorPagesPizza.Data.RazorPagesPizzaContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | [BindProperty] 24 | public Pizza Pizza { get; set; } = default!; 25 | 26 | public async Task OnGetAsync(int? id) 27 | { 28 | if (id == null || _context.Pizza == null) 29 | { 30 | return NotFound(); 31 | } 32 | 33 | var pizza = await _context.Pizza.FirstOrDefaultAsync(m => m.Id == id); 34 | if (pizza == null) 35 | { 36 | return NotFound(); 37 | } 38 | Pizza = pizza; 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(Pizza).State = EntityState.Modified; 52 | 53 | try 54 | { 55 | await _context.SaveChangesAsync(); 56 | } 57 | catch (DbUpdateConcurrencyException) 58 | { 59 | if (!PizzaExists(Pizza.Id)) 60 | { 61 | return NotFound(); 62 | } 63 | else 64 | { 65 | throw; 66 | } 67 | } 68 | 69 | return RedirectToPage("./Index"); 70 | } 71 | 72 | private bool PizzaExists(int id) 73 | { 74 | return (_context.Pizza?.Any(e => e.Id == id)).GetValueOrDefault(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace RazorPagesPizza.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 | } -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model RazorPagesPizza.Pages.IndexModel 3 | 4 | @{ 5 | ViewData["Title"] = "Index"; 6 | } 7 | 8 |

Index

9 | 10 |

11 | Create New 12 |

13 | 14 | 15 | 16 | 19 | 22 | 25 | 26 | 27 | 28 | 29 | @foreach (var item in Model.Pizza) { 30 | 31 | 34 | 37 | 40 | 45 | 46 | } 47 | 48 |
17 | @Html.DisplayNameFor(model => model.Pizza[0].Name) 18 | 20 | @Html.DisplayNameFor(model => model.Pizza[0].IsGlutenFree) 21 | 23 | @Html.DisplayNameFor(model => model.Pizza[0].Price) 24 |
32 | @Html.DisplayFor(modelItem => item.Name) 33 | 35 | @Html.DisplayFor(modelItem => item.IsGlutenFree) 36 | 38 | @Html.DisplayFor(modelItem => item.Price) 39 | 41 | Edit | 42 | Details | 43 | Delete 44 |
49 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/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 RazorPagesPizza.Data; 9 | using RazorPagesPizza.Models; 10 | 11 | namespace RazorPagesPizza.Pages 12 | { 13 | public class IndexModel : PageModel 14 | { 15 | private readonly RazorPagesPizza.Data.RazorPagesPizzaContext _context; 16 | 17 | public IndexModel(RazorPagesPizza.Data.RazorPagesPizzaContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public IList Pizza { get;set; } = default!; 23 | 24 | public async Task OnGetAsync() 25 | { 26 | if (_context.Pizza != null) 27 | { 28 | Pizza = await _context.Pizza.ToListAsync(); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/Privacy.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | namespace RazorPagesPizza.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 | } -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - RazorPagesPizza 7 | 8 | 9 | 10 | 11 | 12 |
13 | 32 |
33 |
34 |
35 | @RenderBody() 36 |
37 |
38 | 39 |
40 |
41 | © 2023 - RazorPagesPizza - Privacy 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | @await RenderSectionAsync("Scripts", required: false) 50 | 51 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using RazorPagesPizza 2 | @namespace RazorPagesPizza.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using RazorPagesPizza.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.UseSqlServer(builder.Configuration.GetConnectionString("RazorPagesPizzaContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesPizzaContext' 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 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:56089", 7 | "sslPort": 44328 8 | } 9 | }, 10 | "profiles": { 11 | "http": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "http://localhost:5101", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "https": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": true, 23 | "launchBrowser": true, 24 | "applicationUrl": "https://localhost:7001;http://localhost:5101", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | }, 29 | "IIS Express": { 30 | "commandName": "IISExpress", 31 | "launchBrowser": true, 32 | "environmentVariables": { 33 | "ASPNETCORE_ENVIRONMENT": "Development" 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql", 5 | "connectionId": "ConnectionStrings:RazorPagesPizzaContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql.local", 5 | "connectionId": "ConnectionStrings:RazorPagesPizzaContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/RazorPagesPizza.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "RazorPagesPizzaContext": "Server=(localdb)\\mssqllocaldb;Database=RazorPagesPizza.Data;Trusted_Connection=True;MultipleActiveResultSets=true" 11 | } 12 | } -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/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 | } -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/wwwroot/favicon.ico -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v5.1.0 (https://getbootstrap.com/) 3 | * Copyright 2011-2021 The Bootstrap Authors 4 | * Copyright 2011-2021 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v5.1.0 (https://getbootstrap.com/) 3 | * Copyright 2011-2021 The Bootstrap Authors 4 | * Copyright 2011-2021 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-right:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-right:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:right}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:right;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:right}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}[type=email],[type=number],[type=tel],[type=url]{direction:ltr}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.rtl.min.css.map */ -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/1-complete/RazorPagesPizza/RazorPagesPizza/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 | -------------------------------------------------------------------------------- /3-razor-pages/add-scaffold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/add-scaffold.png -------------------------------------------------------------------------------- /3-razor-pages/additional-info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/additional-info.png -------------------------------------------------------------------------------- /3-razor-pages/config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/config.png -------------------------------------------------------------------------------- /3-razor-pages/new-scaffold-dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/new-scaffold-dialog.png -------------------------------------------------------------------------------- /3-razor-pages/np.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/np.png -------------------------------------------------------------------------------- /3-razor-pages/overwrite-warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/overwrite-warning.png -------------------------------------------------------------------------------- /3-razor-pages/pizza-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/pizza-list.png -------------------------------------------------------------------------------- /3-razor-pages/pmc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/pmc.png -------------------------------------------------------------------------------- /3-razor-pages/scaffold-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/scaffold-settings.png -------------------------------------------------------------------------------- /3-razor-pages/se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/se.png -------------------------------------------------------------------------------- /3-razor-pages/start-window-create-new-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/3-razor-pages/start-window-create-new-project.png -------------------------------------------------------------------------------- /4-minimal-api/0-start/PizzaStore/PizzaStore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /4-minimal-api/0-start/PizzaStore/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | var app = builder.Build(); 3 | 4 | app.MapGet("/", () => "Hello World!"); 5 | 6 | app.Run(); 7 | -------------------------------------------------------------------------------- /4-minimal-api/0-start/PizzaStore/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:1201", 7 | "sslPort": 44373 8 | } 9 | }, 10 | "profiles": { 11 | "http": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "http://localhost:5112", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "https": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": true, 23 | "launchBrowser": true, 24 | "applicationUrl": "https://localhost:7192;http://localhost:5112", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | }, 29 | "IIS Express": { 30 | "commandName": "IISExpress", 31 | "launchBrowser": true, 32 | "environmentVariables": { 33 | "ASPNETCORE_ENVIRONMENT": "Development" 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /4-minimal-api/0-start/PizzaStore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /4-minimal-api/0-start/PizzaStore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /4-minimal-api/1-complete/PizzaStore/Db.cs: -------------------------------------------------------------------------------- 1 | namespace PizzaStore.DB; 2 | 3 | public record Pizza 4 | { 5 | public int Id {get; set;} 6 | public string ? Name { get; set; } 7 | } 8 | 9 | public class PizzaDB 10 | { 11 | private static List _pizzas = new List() 12 | { 13 | new Pizza{ Id=1, Name="Cheese" }, 14 | new Pizza{ Id=2, Name="Pepperoni" }, 15 | new Pizza{ Id=3, Name="Pineapple extravaganza"} 16 | }; 17 | 18 | public static List GetPizzas() 19 | { 20 | return _pizzas; 21 | } 22 | 23 | public static Pizza ? GetPizza(int id) 24 | { 25 | return _pizzas.SingleOrDefault(pizza => pizza.Id == id); 26 | } 27 | 28 | public static Pizza CreatePizza(Pizza pizza) 29 | { 30 | _pizzas.Add(pizza); 31 | return pizza; 32 | } 33 | 34 | public static Pizza UpdatePizza(Pizza update) 35 | { 36 | _pizzas = _pizzas.Select(pizza => 37 | { 38 | if (pizza.Id == update.Id) 39 | { 40 | pizza.Name = update.Name; 41 | } 42 | return pizza; 43 | }).ToList(); 44 | return update; 45 | } 46 | 47 | public static void RemovePizza(int id) 48 | { 49 | _pizzas = _pizzas.FindAll(pizza => pizza.Id != id).ToList(); 50 | } 51 | } -------------------------------------------------------------------------------- /4-minimal-api/1-complete/PizzaStore/PizzaStore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /4-minimal-api/1-complete/PizzaStore/Program.cs: -------------------------------------------------------------------------------- 1 | using PizzaStore.DB; 2 | using Microsoft.OpenApi.Models; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | builder.Services.AddEndpointsApiExplorer(); 7 | builder.Services.AddSwaggerGen(c => 8 | { 9 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "PizzaStore API", Description = "Making the Pizzas you love", Version = "v1" }); 10 | }); 11 | 12 | var app = builder.Build(); 13 | 14 | if (app.Environment.IsDevelopment()) 15 | { 16 | app.UseDeveloperExceptionPage(); 17 | app.UseSwagger(); 18 | app.UseSwaggerUI(c => // UseSwaggerUI Protected by if (env.IsDevelopment()) 19 | { 20 | c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzaStore API V1"); 21 | }); 22 | } 23 | 24 | app.MapGet("/", () => "Hello World!"); 25 | 26 | app.MapGet("/pizzas/{id}", (int id) => PizzaDB.GetPizza(id)); 27 | app.MapGet("/pizzas", () => PizzaDB.GetPizzas()); 28 | app.MapPost("/pizzas", (Pizza pizza) => PizzaDB.CreatePizza(pizza)); 29 | app.MapPut("/pizzas", (Pizza pizza) => PizzaDB.UpdatePizza(pizza)); 30 | app.MapDelete("/pizzas/{id}", (int id) => PizzaDB.RemovePizza(id)); 31 | 32 | app.Run(); 33 | -------------------------------------------------------------------------------- /4-minimal-api/1-complete/PizzaStore/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:1201", 7 | "sslPort": 44373 8 | } 9 | }, 10 | "profiles": { 11 | "http": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "http://localhost:5112", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "https": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": true, 23 | "launchBrowser": true, 24 | "applicationUrl": "https://localhost:7192;http://localhost:5112", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | }, 29 | "IIS Express": { 30 | "commandName": "IISExpress", 31 | "launchBrowser": true, 32 | "environmentVariables": { 33 | "ASPNETCORE_ENVIRONMENT": "Development" 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /4-minimal-api/1-complete/PizzaStore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /4-minimal-api/1-complete/PizzaStore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /4-minimal-api/swagger-crud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/4-minimal-api/swagger-crud.png -------------------------------------------------------------------------------- /4-minimal-api/swagger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/4-minimal-api/swagger.png -------------------------------------------------------------------------------- /5-blazor/0-start/Blazor.ConnectFour.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32414.248 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectFour", "ConnectFour\ConnectFour.csproj", "{A39A8B5F-BB76-48CD-BA4E-F0733604EB79}" 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 | {A39A8B5F-BB76-48CD-BA4E-F0733604EB79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {A39A8B5F-BB76-48CD-BA4E-F0733604EB79}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {A39A8B5F-BB76-48CD-BA4E-F0733604EB79}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {A39A8B5F-BB76-48CD-BA4E-F0733604EB79}.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 = {19E21953-6482-4D77-B071-6C6EE7515DDB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Board.razor: -------------------------------------------------------------------------------- 1 | 

Board

2 | 3 | @code { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Board.razor.css: -------------------------------------------------------------------------------- 1 | div { 2 | position: relative; 3 | } 4 | 5 | nav { 6 | top: 4em; 7 | width: 30em; 8 | display: inline-flex; 9 | flex-direction: row; 10 | margin-left: 10px; 11 | } 12 | 13 | nav span { 14 | width: 4em; 15 | text-align: center; 16 | cursor: pointer; 17 | font-size: 1em; 18 | } 19 | 20 | div.board { 21 | margin-top: 1em; 22 | flex-wrap: wrap; 23 | width: 30em; 24 | height: 24em; 25 | overflow: hidden; 26 | display: inline-flex; 27 | flex-direction: row; 28 | flex-wrap: wrap; 29 | z-index: -5; 30 | row-gap: 0; 31 | pointer-events: none; 32 | border-left: 10px solid var(--board-bg); 33 | } 34 | 35 | span.container { 36 | width: 4em; 37 | height: 4em; 38 | margin: 0; 39 | padding: 4px; 40 | overflow: hidden; 41 | background-color: transparent; 42 | position: relative; 43 | z-index: -2; 44 | pointer-events: none; 45 | } 46 | 47 | .container span { 48 | width: 3.5em; 49 | height: 3.5em; 50 | border-radius: 50%; 51 | box-shadow: 0 0 0 3em var(--board-bg); 52 | left: 0px; 53 | position: absolute; 54 | display: block; 55 | z-index: 5; 56 | pointer-events: none; 57 | } 58 | 59 | .player1, .player2 { 60 | width: 3.5em; 61 | height: 3.5em; 62 | border-radius: 50%; 63 | left: 0px; 64 | top: 0px; 65 | position: absolute; 66 | display: block; 67 | z-index: -8; 68 | } 69 | 70 | .player1 { 71 | background-color: var(--player1); 72 | animation-timing-function: cubic-bezier(.5, 0.05, 1, .5); 73 | animation-iteration-count: 1; 74 | animation-fill-mode: forwards; 75 | box-shadow: 0 0 0 4px var(--player1); 76 | } 77 | 78 | .player2 { 79 | background-color: var(--player2); 80 | animation-timing-function: cubic-bezier(.5, 0.05, 1, .5); 81 | animation-iteration-count: 1; 82 | animation-fill-mode: forwards; 83 | box-shadow: 0 0 0 4px var(--player2); 84 | } 85 | 86 | .col0 { 87 | left: calc(0em + 9px); 88 | } 89 | 90 | .col1 { 91 | left: calc(4em + 9px); 92 | } 93 | 94 | .col2 { 95 | left: calc(8em + 9px); 96 | } 97 | 98 | .col3 { 99 | left: calc(12em + 9px); 100 | } 101 | 102 | .col4 { 103 | left: calc(16em + 9px); 104 | } 105 | 106 | .col5 { 107 | left: calc(20em + 9px); 108 | } 109 | 110 | .col6 { 111 | left: calc(24em + 9px); 112 | } 113 | 114 | .drop1 { 115 | animation-duration: 1s; 116 | animation-name: drop1; 117 | } 118 | 119 | .drop2 { 120 | animation-duration: 1.5s; 121 | animation-name: drop2; 122 | } 123 | 124 | .drop3 { 125 | animation-duration: 1.6s; 126 | animation-name: drop3; 127 | } 128 | 129 | .drop4 { 130 | animation-duration: 1.7s; 131 | animation-name: drop4; 132 | } 133 | 134 | .drop5 { 135 | animation-duration: 1.8s; 136 | animation-name: drop5; 137 | } 138 | 139 | .drop6 { 140 | animation-duration: 1.9s; 141 | animation-name: drop6; 142 | } 143 | 144 | @keyframes drop1 { 145 | 75%, 90%, 97%, 100% { 146 | transform: translateY(1.27em); 147 | } 148 | 149 | 80% { 150 | transform: translateY(0.4em); 151 | } 152 | 153 | /*-15% */ 154 | 95% { 155 | transform: translateY(0.8em); 156 | } 157 | 158 | /* -7% */ 159 | 99% { 160 | transform: translateY(1.0em); 161 | } 162 | 163 | /* -3% */ 164 | } 165 | 166 | @keyframes drop2 { 167 | 75%, 90%, 97%, 100% { 168 | transform: translateY(5.27em); 169 | } 170 | 171 | 80% { 172 | transform: translateY(3.8em); 173 | } 174 | 175 | /*-15% */ 176 | 95% { 177 | transform: translateY(4.6em); 178 | } 179 | 180 | /* -7% */ 181 | 99% { 182 | transform: translateY(4.9em); 183 | } 184 | 185 | /* -3% */ 186 | } 187 | 188 | @keyframes drop3 { 189 | 75%, 90%, 97%, 100% { 190 | transform: translateY(9.27em); 191 | } 192 | 193 | 80% { 194 | transform: translateY(7.2em); 195 | } 196 | 197 | /*-15% */ 198 | 95% { 199 | transform: translateY(8.3em); 200 | } 201 | 202 | /* -7% */ 203 | 99% { 204 | transform: translateY(8.8em); 205 | } 206 | 207 | /* -3% */ 208 | } 209 | 210 | @keyframes drop4 { 211 | 75%, 90%, 97%, 100% { 212 | transform: translateY(13.27em); 213 | } 214 | 215 | 80% { 216 | transform: translateY(10.6em); 217 | } 218 | 219 | /*-15% */ 220 | 95% { 221 | transform: translateY(12em); 222 | } 223 | 224 | /* -7% */ 225 | 99% { 226 | transform: translateY(12.7em); 227 | } 228 | 229 | /* -3% */ 230 | } 231 | 232 | @keyframes drop5 { 233 | 75%, 90%, 97%, 100% { 234 | transform: translateY(17.27em); 235 | } 236 | 237 | 80% { 238 | transform: translateY(14em); 239 | } 240 | 241 | /*-15% */ 242 | 95% { 243 | transform: translateY(15.7em); 244 | } 245 | 246 | /* -7% */ 247 | 99% { 248 | transform: translateY(16.5em); 249 | } 250 | 251 | /* -3% */ 252 | } 253 | 254 | @keyframes drop6 { 255 | 75%, 90%, 97%, 100% { 256 | transform: translateY(21.27em); 257 | } 258 | 259 | 80% { 260 | transform: translateY(17.4em); 261 | } 262 | 263 | 95% { 264 | transform: translateY(19.4em); 265 | } 266 | 267 | 99% { 268 | transform: translateY(20.4em); 269 | } 270 | } -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Layout/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row { 41 | justify-content: space-between; 42 | } 43 | 44 | .top-row ::deep a, .top-row ::deep .btn-link { 45 | margin-left: 0; 46 | } 47 | } 48 | 49 | @media (min-width: 641px) { 50 | .page { 51 | flex-direction: row; 52 | } 53 | 54 | .sidebar { 55 | width: 250px; 56 | height: 100vh; 57 | position: sticky; 58 | top: 0; 59 | } 60 | 61 | .top-row { 62 | position: sticky; 63 | top: 0; 64 | z-index: 1; 65 | } 66 | 67 | .top-row.auth ::deep a:first-child { 68 | flex: 1; 69 | text-align: right; 70 | width: 0; 71 | } 72 | 73 | .top-row, article { 74 | padding-left: 2rem !important; 75 | padding-right: 1.5rem !important; 76 | } 77 | } 78 | 79 | #blazor-error-ui { 80 | background: lightyellow; 81 | bottom: 0; 82 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 83 | display: none; 84 | left: 0; 85 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 86 | position: fixed; 87 | width: 100%; 88 | z-index: 1000; 89 | } 90 | 91 | #blazor-error-ui .dismiss { 92 | cursor: pointer; 93 | position: absolute; 94 | right: 0.75rem; 95 | top: 0.5rem; 96 | } 97 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 30 | 31 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Layout/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | appearance: none; 3 | cursor: pointer; 4 | width: 3.5rem; 5 | height: 2.5rem; 6 | color: white; 7 | position: absolute; 8 | top: 0.5rem; 9 | right: 1rem; 10 | border: 1px solid rgba(255, 255, 255, 0.1); 11 | background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1); 12 | } 13 | 14 | .navbar-toggler:checked { 15 | background-color: rgba(255, 255, 255, 0.5); 16 | } 17 | 18 | .top-row { 19 | height: 3.5rem; 20 | background-color: rgba(0,0,0,0.4); 21 | } 22 | 23 | .navbar-brand { 24 | font-size: 1.1rem; 25 | } 26 | 27 | .bi { 28 | display: inline-block; 29 | position: relative; 30 | width: 1.25rem; 31 | height: 1.25rem; 32 | margin-right: 0.75rem; 33 | top: -1px; 34 | background-size: cover; 35 | } 36 | 37 | .bi-house-door-fill-nav-menu { 38 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E"); 39 | } 40 | 41 | .bi-plus-square-fill-nav-menu { 42 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E"); 43 | } 44 | 45 | .bi-list-nested-nav-menu { 46 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E"); 47 | } 48 | 49 | .nav-item { 50 | font-size: 0.9rem; 51 | padding-bottom: 0.5rem; 52 | } 53 | 54 | .nav-item:first-of-type { 55 | padding-top: 1rem; 56 | } 57 | 58 | .nav-item:last-of-type { 59 | padding-bottom: 1rem; 60 | } 61 | 62 | .nav-item ::deep .nav-link { 63 | color: #d7d7d7; 64 | background: none; 65 | border: none; 66 | border-radius: 4px; 67 | height: 3rem; 68 | display: flex; 69 | align-items: center; 70 | line-height: 3rem; 71 | width: 100%; 72 | } 73 | 74 | .nav-item ::deep a.active { 75 | background-color: rgba(255,255,255,0.37); 76 | color: white; 77 | } 78 | 79 | .nav-item ::deep .nav-link:hover { 80 | background-color: rgba(255,255,255,0.1); 81 | color: white; 82 | } 83 | 84 | .nav-scrollable { 85 | display: none; 86 | } 87 | 88 | .navbar-toggler:checked ~ .nav-scrollable { 89 | display: block; 90 | } 91 | 92 | @media (min-width: 641px) { 93 | .navbar-toggler { 94 | display: none; 95 | } 96 | 97 | .nav-scrollable { 98 | /* Never collapse the sidebar for wide screens */ 99 | display: block; 100 | 101 | /* Allow sidebar to scroll for tall menus */ 102 | height: calc(100vh - 3.5rem); 103 | overflow-y: auto; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | @rendermode InteractiveServer 3 | 4 | Counter 5 | 6 |

Counter

7 | 8 |

Current count: @currentCount

9 | 10 | 11 | 12 | @code { 13 | private int currentCount = 0; 14 | 15 | private void IncrementCount() 16 | { 17 | currentCount++; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/Error" 2 | @using System.Diagnostics 3 | 4 | Error 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (ShowRequestId) 10 | { 11 |

12 | Request ID: @RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

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

26 | 27 | @code{ 28 | [CascadingParameter] 29 | private HttpContext? HttpContext { get; set; } 30 | 31 | private string? RequestId { get; set; } 32 | private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 33 | 34 | protected override void OnInitialized() => 35 | RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; 36 | } 37 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Connect Four 4 | 5 | 6 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Pages/Weather.razor: -------------------------------------------------------------------------------- 1 | @page "/weather" 2 | @attribute [StreamRendering] 3 | 4 | Weather 5 | 6 |

Weather

7 | 8 |

This component demonstrates showing data.

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

Loading...

13 | } 14 | else 15 | { 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | @foreach (var forecast in forecasts) 27 | { 28 | 29 | 30 | 31 | 32 | 33 | 34 | } 35 | 36 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
37 | } 38 | 39 | @code { 40 | private WeatherForecast[]? forecasts; 41 | 42 | protected override async Task OnInitializedAsync() 43 | { 44 | // Simulate asynchronous loading to demonstrate streaming rendering 45 | await Task.Delay(500); 46 | 47 | var startDate = DateOnly.FromDateTime(DateTime.Now); 48 | var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; 49 | forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast 50 | { 51 | Date = startDate.AddDays(index), 52 | TemperatureC = Random.Shared.Next(-20, 55), 53 | Summary = summaries[Random.Shared.Next(summaries.Length)] 54 | }).ToArray(); 55 | } 56 | 57 | private class WeatherForecast 58 | { 59 | public DateOnly Date { get; set; } 60 | public int TemperatureC { get; set; } 61 | public string? Summary { get; set; } 62 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/Routes.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using ConnectFour 10 | @using ConnectFour.Components 11 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/ConnectFour.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/GameState.cs: -------------------------------------------------------------------------------- 1 | namespace ConnectFour; 2 | 3 | public class GameState 4 | { 5 | 6 | static GameState() 7 | { 8 | CalculateWinningPlaces(); 9 | } 10 | 11 | /// 12 | /// Indicate whether a player has won, the game is a tie, or game in ongoing 13 | /// 14 | public enum WinState 15 | { 16 | No_Winner = 0, 17 | Player1_Wins = 1, 18 | Player2_Wins = 2, 19 | Tie = 3 20 | } 21 | 22 | /// 23 | /// The player whose turn it is. By default, player 1 starts first 24 | /// 25 | public int PlayerTurn => TheBoard.Count(x => x != 0) % 2 + 1; 26 | 27 | /// 28 | /// Number of turns completed and pieces played so far in the game 29 | /// 30 | public int CurrentTurn { get { return TheBoard.Count(x => x != 0); } } 31 | 32 | public static readonly List WinningPlaces = new(); 33 | 34 | public static void CalculateWinningPlaces() 35 | { 36 | 37 | // Horizontal rows 38 | for (byte row=0;row<6;row++){ 39 | 40 | byte rowCol1 = (byte)(row * 7); 41 | byte rowColEnd = (byte)((row + 1) * 7 - 1); 42 | byte checkCol = rowCol1; 43 | while (checkCol <= rowColEnd-3) 44 | { 45 | WinningPlaces.Add(new int[] { 46 | checkCol, 47 | (byte)(checkCol + 1), 48 | (byte)(checkCol + 2), 49 | (byte)(checkCol + 3) 50 | }); 51 | checkCol++; 52 | } 53 | 54 | } 55 | 56 | // Vertical Columns 57 | for (byte col = 0; col < 7; col++) 58 | { 59 | 60 | byte colRow1 = col; 61 | byte colRowEnd = (byte)(35+col); 62 | byte checkRow = colRow1; 63 | while (checkRow <= 14+col) 64 | { 65 | WinningPlaces.Add(new int[] { 66 | checkRow, 67 | (byte)(checkRow + 7), 68 | (byte)(checkRow + 14), 69 | (byte)(checkRow + 21) 70 | }); 71 | checkRow+=7; 72 | } 73 | 74 | } 75 | 76 | // forward slash diagonal "/" 77 | for (byte col = 0; col < 4; col++) 78 | { 79 | 80 | // starting column must be 0-3 81 | byte colRow1 = (byte)(21 + col); 82 | byte colRowEnd = (byte)(35 + col); 83 | byte checkPos = colRow1; 84 | while (checkPos <= colRowEnd) 85 | { 86 | WinningPlaces.Add(new int[] { 87 | checkPos, 88 | (byte)(checkPos - 6), 89 | (byte)(checkPos - 12), 90 | (byte)(checkPos - 18) 91 | }); 92 | checkPos += 7; 93 | } 94 | 95 | } 96 | 97 | // back slash diaganol "\" 98 | for (byte col = 0; col < 4; col++) 99 | { 100 | 101 | // starting column must be 0-3 102 | byte colRow1 = (byte)(0 + col); 103 | byte colRowEnd = (byte)(14 + col); 104 | byte checkPos = colRow1; 105 | while (checkPos <= colRowEnd) 106 | { 107 | WinningPlaces.Add(new int[] { 108 | checkPos, 109 | (byte)(checkPos + 8), 110 | (byte)(checkPos + 16), 111 | (byte)(checkPos + 24) 112 | }); 113 | checkPos += 7; 114 | } 115 | 116 | } 117 | 118 | 119 | } 120 | 121 | /// 122 | /// Check the state of the board for a winning scenario 123 | /// 124 | /// 0 - no winner, 1 - player 1 wins, 2 - player 2 wins, 3 - draw 125 | public WinState CheckForWin() 126 | { 127 | 128 | // Exit immediately if less than 7 pieces are played 129 | if (TheBoard.Count(x => x != 0) < 7) return WinState.No_Winner; 130 | 131 | foreach (var scenario in WinningPlaces) 132 | { 133 | 134 | if (TheBoard[scenario[0]] == 0) continue; 135 | 136 | if (TheBoard[scenario[0]] == 137 | TheBoard[scenario[1]] && 138 | TheBoard[scenario[1]] == 139 | TheBoard[scenario[2]] && 140 | TheBoard[scenario[2]] == 141 | TheBoard[scenario[3]]) return (WinState)TheBoard[scenario[0]]; 142 | 143 | } 144 | 145 | if (TheBoard.Count(x => x != 0) == 42) return WinState.Tie; 146 | 147 | return WinState.No_Winner; 148 | 149 | } 150 | 151 | /// 152 | /// Takes the current turn and places a piece in the 0-indexed column requested 153 | /// 154 | /// 0-indexed column to place the piece into 155 | /// The final array index where the piece resides 156 | public byte PlayPiece(int column) 157 | { 158 | 159 | // Check for a current win 160 | if (CheckForWin() != 0) throw new ArgumentException("Game is over"); 161 | 162 | // Check the column 163 | if (TheBoard[column] != 0) throw new ArgumentException("Column is full"); 164 | 165 | // Drop the piece in 166 | var landingSpot = column; 167 | for (var i=column;i<42;i+=7) 168 | { 169 | if (TheBoard[landingSpot + 7] != 0) break; 170 | landingSpot = i; 171 | } 172 | 173 | TheBoard[landingSpot] = PlayerTurn; 174 | 175 | return ConvertLandingSpotToRow(landingSpot); 176 | 177 | } 178 | 179 | public List TheBoard { get; private set; } = new List(new int[42]); 180 | 181 | public void ResetBoard() { 182 | TheBoard = new List(new int[42]); 183 | } 184 | 185 | private byte ConvertLandingSpotToRow(int landingSpot) 186 | { 187 | 188 | return (byte)(Math.Floor(landingSpot / (decimal)7) + 1); 189 | 190 | } 191 | 192 | } -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Program.cs: -------------------------------------------------------------------------------- 1 | using ConnectFour; 2 | using ConnectFour.Components; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | // Add services to the container. 7 | builder.Services.AddRazorComponents() 8 | .AddInteractiveServerComponents(); 9 | 10 | var app = builder.Build(); 11 | 12 | // Configure the HTTP request pipeline. 13 | if (!app.Environment.IsDevelopment()) 14 | { 15 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 16 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 17 | app.UseHsts(); 18 | } 19 | 20 | app.UseHttpsRedirection(); 21 | 22 | app.UseStaticFiles(); 23 | app.UseAntiforgery(); 24 | 25 | app.MapRazorComponents() 26 | .AddInteractiveServerRenderMode(); 27 | 28 | app.Run(); 29 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:16315", 7 | "sslPort": 44390 8 | } 9 | }, 10 | "profiles": { 11 | "http": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "http://localhost:5007", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "https": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": true, 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "applicationUrl": "https://localhost:7000;http://localhost:5007", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 34 | "environmentVariables": { 35 | "ASPNETCORE_ENVIRONMENT": "Development" 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/wwwroot/app.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 3 | } 4 | 5 | a, .btn-link { 6 | color: #006bb7; 7 | } 8 | 9 | .btn-primary { 10 | color: #fff; 11 | background-color: #1b6ec2; 12 | border-color: #1861ac; 13 | } 14 | 15 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 16 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 17 | } 18 | 19 | .content { 20 | padding-top: 1.1rem; 21 | } 22 | 23 | h1:focus { 24 | outline: none; 25 | } 26 | 27 | .valid.modified:not([type=checkbox]) { 28 | outline: 1px solid #26b050; 29 | } 30 | 31 | .invalid { 32 | outline: 1px solid #e50000; 33 | } 34 | 35 | .validation-message { 36 | color: #e50000; 37 | } 38 | 39 | .blazor-error-boundary { 40 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 41 | padding: 1rem 1rem 1rem 3.7rem; 42 | color: white; 43 | } 44 | 45 | .blazor-error-boundary::after { 46 | content: "An error has occurred." 47 | } 48 | 49 | .darker-border-checkbox.form-check-input { 50 | border-color: #929292; 51 | } 52 | -------------------------------------------------------------------------------- /5-blazor/0-start/ConnectFour/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/0-start/ConnectFour/wwwroot/favicon.png -------------------------------------------------------------------------------- /5-blazor/1-complete/Blazor.ConnectFour.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32414.248 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectFour", "ConnectFour\ConnectFour.csproj", "{A39A8B5F-BB76-48CD-BA4E-F0733604EB79}" 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 | {A39A8B5F-BB76-48CD-BA4E-F0733604EB79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {A39A8B5F-BB76-48CD-BA4E-F0733604EB79}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {A39A8B5F-BB76-48CD-BA4E-F0733604EB79}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {A39A8B5F-BB76-48CD-BA4E-F0733604EB79}.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 = {19E21953-6482-4D77-B071-6C6EE7515DDB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/Board.razor: -------------------------------------------------------------------------------- 1 | @using System.Drawing 2 | @inject GameState State 3 | 4 | 5 | 12 | 13 | 14 | 21 | 22 |
23 | @winnerMessage 24 |
25 | @errorMessage 26 | @CurrentTurn 27 |
28 | 29 |
30 |
31 | @for (var i = 0; i < 42; i++) 32 | { 33 | 34 | 35 | 36 | } 37 |
38 | @for (var i = 0; i < 42; i++) 39 | { 40 | 41 | } 42 |
43 | 44 | @code { 45 | private string[] pieces = new string[42]; 46 | private string winnerMessage = string.Empty; 47 | private string errorMessage = string.Empty; 48 | 49 | private string CurrentTurn => (winnerMessage == string.Empty) ? $"Player {State.PlayerTurn}'s Turn" : ""; 50 | private string ResetStyle => (winnerMessage == string.Empty) ? "display: none;" : ""; 51 | 52 | [Parameter] 53 | public Color BoardColor { get; set; } = ColorTranslator.FromHtml("yellow"); 54 | 55 | [Parameter] 56 | public Color Player1Color { get; set; } = ColorTranslator.FromHtml("red"); 57 | 58 | [Parameter] 59 | public Color Player2Color { get; set; } = ColorTranslator.FromHtml("blue"); 60 | 61 | protected override void OnInitialized() 62 | { 63 | State.ResetBoard(); 64 | } 65 | 66 | private void PlayPiece(byte col) 67 | { 68 | errorMessage = string.Empty; 69 | try 70 | { 71 | var player = State.PlayerTurn; 72 | var turn = State.CurrentTurn; 73 | var landingRow = State.PlayPiece(col); 74 | pieces[turn] = $"player{player} col{col} drop{landingRow}"; 75 | } 76 | catch (ArgumentException ex) 77 | { 78 | errorMessage = ex.Message; 79 | } 80 | winnerMessage = State.CheckForWin() switch 81 | { 82 | GameState.WinState.Player1_Wins => "Player 1 Wins!", 83 | GameState.WinState.Player2_Wins => "Player 2 Wins!", 84 | GameState.WinState.Tie => "It's a tie!", 85 | _ => "" 86 | }; 87 | } 88 | 89 | void ResetGame() 90 | { 91 | State.ResetBoard(); 92 | winnerMessage = string.Empty; 93 | errorMessage = string.Empty; 94 | pieces = new string[42]; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/Board.razor.css: -------------------------------------------------------------------------------- 1 | div { 2 | position: relative; 3 | } 4 | 5 | nav { 6 | top: 4em; 7 | width: 30em; 8 | display: inline-flex; 9 | flex-direction: row; 10 | margin-left: 10px; 11 | } 12 | 13 | nav span { 14 | width: 4em; 15 | text-align: center; 16 | cursor: pointer; 17 | font-size: 1em; 18 | } 19 | 20 | div.board { 21 | margin-top: 1em; 22 | flex-wrap: wrap; 23 | width: 30em; 24 | height: 24em; 25 | overflow: hidden; 26 | display: inline-flex; 27 | flex-direction: row; 28 | flex-wrap: wrap; 29 | z-index: -5; 30 | row-gap: 0; 31 | pointer-events: none; 32 | border-left: 10px solid var(--board-bg); 33 | } 34 | 35 | span.container { 36 | width: 4em; 37 | height: 4em; 38 | margin: 0; 39 | padding: 4px; 40 | overflow: hidden; 41 | background-color: transparent; 42 | position: relative; 43 | z-index: -2; 44 | pointer-events: none; 45 | } 46 | 47 | .container span { 48 | width: 3.5em; 49 | height: 3.5em; 50 | border-radius: 50%; 51 | box-shadow: 0 0 0 3em var(--board-bg); 52 | left: 0px; 53 | position: absolute; 54 | display: block; 55 | z-index: 5; 56 | pointer-events: none; 57 | } 58 | 59 | .player1, .player2 { 60 | width: 3.5em; 61 | height: 3.5em; 62 | border-radius: 50%; 63 | left: 0px; 64 | top: 0px; 65 | position: absolute; 66 | display: block; 67 | z-index: -8; 68 | } 69 | 70 | .player1 { 71 | background-color: var(--player1); 72 | animation-timing-function: cubic-bezier(.5, 0.05, 1, .5); 73 | animation-iteration-count: 1; 74 | animation-fill-mode: forwards; 75 | box-shadow: 0 0 0 4px var(--player1); 76 | } 77 | 78 | .player2 { 79 | background-color: var(--player2); 80 | animation-timing-function: cubic-bezier(.5, 0.05, 1, .5); 81 | animation-iteration-count: 1; 82 | animation-fill-mode: forwards; 83 | box-shadow: 0 0 0 4px var(--player2); 84 | } 85 | 86 | .col0 { 87 | left: calc(0em + 9px); 88 | } 89 | 90 | .col1 { 91 | left: calc(4em + 9px); 92 | } 93 | 94 | .col2 { 95 | left: calc(8em + 9px); 96 | } 97 | 98 | .col3 { 99 | left: calc(12em + 9px); 100 | } 101 | 102 | .col4 { 103 | left: calc(16em + 9px); 104 | } 105 | 106 | .col5 { 107 | left: calc(20em + 9px); 108 | } 109 | 110 | .col6 { 111 | left: calc(24em + 9px); 112 | } 113 | 114 | .drop1 { 115 | animation-duration: 1s; 116 | animation-name: drop1; 117 | } 118 | 119 | .drop2 { 120 | animation-duration: 1.5s; 121 | animation-name: drop2; 122 | } 123 | 124 | .drop3 { 125 | animation-duration: 1.6s; 126 | animation-name: drop3; 127 | } 128 | 129 | .drop4 { 130 | animation-duration: 1.7s; 131 | animation-name: drop4; 132 | } 133 | 134 | .drop5 { 135 | animation-duration: 1.8s; 136 | animation-name: drop5; 137 | } 138 | 139 | .drop6 { 140 | animation-duration: 1.9s; 141 | animation-name: drop6; 142 | } 143 | 144 | @keyframes drop1 { 145 | 75%, 90%, 97%, 100% { 146 | transform: translateY(1.27em); 147 | } 148 | 149 | 80% { 150 | transform: translateY(0.4em); 151 | } 152 | 153 | /*-15% */ 154 | 95% { 155 | transform: translateY(0.8em); 156 | } 157 | 158 | /* -7% */ 159 | 99% { 160 | transform: translateY(1.0em); 161 | } 162 | 163 | /* -3% */ 164 | } 165 | 166 | @keyframes drop2 { 167 | 75%, 90%, 97%, 100% { 168 | transform: translateY(5.27em); 169 | } 170 | 171 | 80% { 172 | transform: translateY(3.8em); 173 | } 174 | 175 | /*-15% */ 176 | 95% { 177 | transform: translateY(4.6em); 178 | } 179 | 180 | /* -7% */ 181 | 99% { 182 | transform: translateY(4.9em); 183 | } 184 | 185 | /* -3% */ 186 | } 187 | 188 | @keyframes drop3 { 189 | 75%, 90%, 97%, 100% { 190 | transform: translateY(9.27em); 191 | } 192 | 193 | 80% { 194 | transform: translateY(7.2em); 195 | } 196 | 197 | /*-15% */ 198 | 95% { 199 | transform: translateY(8.3em); 200 | } 201 | 202 | /* -7% */ 203 | 99% { 204 | transform: translateY(8.8em); 205 | } 206 | 207 | /* -3% */ 208 | } 209 | 210 | @keyframes drop4 { 211 | 75%, 90%, 97%, 100% { 212 | transform: translateY(13.27em); 213 | } 214 | 215 | 80% { 216 | transform: translateY(10.6em); 217 | } 218 | 219 | /*-15% */ 220 | 95% { 221 | transform: translateY(12em); 222 | } 223 | 224 | /* -7% */ 225 | 99% { 226 | transform: translateY(12.7em); 227 | } 228 | 229 | /* -3% */ 230 | } 231 | 232 | @keyframes drop5 { 233 | 75%, 90%, 97%, 100% { 234 | transform: translateY(17.27em); 235 | } 236 | 237 | 80% { 238 | transform: translateY(14em); 239 | } 240 | 241 | /*-15% */ 242 | 95% { 243 | transform: translateY(15.7em); 244 | } 245 | 246 | /* -7% */ 247 | 99% { 248 | transform: translateY(16.5em); 249 | } 250 | 251 | /* -3% */ 252 | } 253 | 254 | @keyframes drop6 { 255 | 75%, 90%, 97%, 100% { 256 | transform: translateY(21.27em); 257 | } 258 | 259 | 80% { 260 | transform: translateY(17.4em); 261 | } 262 | 263 | 95% { 264 | transform: translateY(19.4em); 265 | } 266 | 267 | 99% { 268 | transform: translateY(20.4em); 269 | } 270 | } -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/Layout/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row { 41 | justify-content: space-between; 42 | } 43 | 44 | .top-row ::deep a, .top-row ::deep .btn-link { 45 | margin-left: 0; 46 | } 47 | } 48 | 49 | @media (min-width: 641px) { 50 | .page { 51 | flex-direction: row; 52 | } 53 | 54 | .sidebar { 55 | width: 250px; 56 | height: 100vh; 57 | position: sticky; 58 | top: 0; 59 | } 60 | 61 | .top-row { 62 | position: sticky; 63 | top: 0; 64 | z-index: 1; 65 | } 66 | 67 | .top-row.auth ::deep a:first-child { 68 | flex: 1; 69 | text-align: right; 70 | width: 0; 71 | } 72 | 73 | .top-row, article { 74 | padding-left: 2rem !important; 75 | padding-right: 1.5rem !important; 76 | } 77 | } 78 | 79 | #blazor-error-ui { 80 | background: lightyellow; 81 | bottom: 0; 82 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 83 | display: none; 84 | left: 0; 85 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 86 | position: fixed; 87 | width: 100%; 88 | z-index: 1000; 89 | } 90 | 91 | #blazor-error-ui .dismiss { 92 | cursor: pointer; 93 | position: absolute; 94 | right: 0.75rem; 95 | top: 0.5rem; 96 | } 97 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 18 | 19 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/Layout/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | appearance: none; 3 | cursor: pointer; 4 | width: 3.5rem; 5 | height: 2.5rem; 6 | color: white; 7 | position: absolute; 8 | top: 0.5rem; 9 | right: 1rem; 10 | border: 1px solid rgba(255, 255, 255, 0.1); 11 | background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1); 12 | } 13 | 14 | .navbar-toggler:checked { 15 | background-color: rgba(255, 255, 255, 0.5); 16 | } 17 | 18 | .top-row { 19 | height: 3.5rem; 20 | background-color: rgba(0,0,0,0.4); 21 | } 22 | 23 | .navbar-brand { 24 | font-size: 1.1rem; 25 | } 26 | 27 | .bi { 28 | display: inline-block; 29 | position: relative; 30 | width: 1.25rem; 31 | height: 1.25rem; 32 | margin-right: 0.75rem; 33 | top: -1px; 34 | background-size: cover; 35 | } 36 | 37 | .bi-house-door-fill-nav-menu { 38 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E"); 39 | } 40 | 41 | .bi-plus-square-fill-nav-menu { 42 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E"); 43 | } 44 | 45 | .bi-list-nested-nav-menu { 46 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E"); 47 | } 48 | 49 | .nav-item { 50 | font-size: 0.9rem; 51 | padding-bottom: 0.5rem; 52 | } 53 | 54 | .nav-item:first-of-type { 55 | padding-top: 1rem; 56 | } 57 | 58 | .nav-item:last-of-type { 59 | padding-bottom: 1rem; 60 | } 61 | 62 | .nav-item ::deep .nav-link { 63 | color: #d7d7d7; 64 | background: none; 65 | border: none; 66 | border-radius: 4px; 67 | height: 3rem; 68 | display: flex; 69 | align-items: center; 70 | line-height: 3rem; 71 | width: 100%; 72 | } 73 | 74 | .nav-item ::deep a.active { 75 | background-color: rgba(255,255,255,0.37); 76 | color: white; 77 | } 78 | 79 | .nav-item ::deep .nav-link:hover { 80 | background-color: rgba(255,255,255,0.1); 81 | color: white; 82 | } 83 | 84 | .nav-scrollable { 85 | display: none; 86 | } 87 | 88 | .navbar-toggler:checked ~ .nav-scrollable { 89 | display: block; 90 | } 91 | 92 | @media (min-width: 641px) { 93 | .navbar-toggler { 94 | display: none; 95 | } 96 | 97 | .nav-scrollable { 98 | /* Never collapse the sidebar for wide screens */ 99 | display: block; 100 | 101 | /* Allow sidebar to scroll for tall menus */ 102 | height: calc(100vh - 3.5rem); 103 | overflow-y: auto; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/Error" 2 | @using System.Diagnostics 3 | 4 | Error 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (ShowRequestId) 10 | { 11 |

12 | Request ID: @RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

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

26 | 27 | @code{ 28 | [CascadingParameter] 29 | private HttpContext? HttpContext { get; set; } 30 | 31 | private string? RequestId { get; set; } 32 | private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 33 | 34 | protected override void OnInitialized() => 35 | RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; 36 | } 37 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Connect Four 4 | 5 | 6 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/Routes.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using ConnectFour 10 | @using ConnectFour.Components 11 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/ConnectFour.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/GameState.cs: -------------------------------------------------------------------------------- 1 | namespace ConnectFour; 2 | 3 | public class GameState 4 | { 5 | 6 | static GameState() 7 | { 8 | CalculateWinningPlaces(); 9 | } 10 | 11 | /// 12 | /// Indicate whether a player has won, the game is a tie, or game in ongoing 13 | /// 14 | public enum WinState 15 | { 16 | No_Winner = 0, 17 | Player1_Wins = 1, 18 | Player2_Wins = 2, 19 | Tie = 3 20 | } 21 | 22 | /// 23 | /// The player whose turn it is. By default, player 1 starts first 24 | /// 25 | public int PlayerTurn => TheBoard.Count(x => x != 0) % 2 + 1; 26 | 27 | /// 28 | /// Number of turns completed and pieces played so far in the game 29 | /// 30 | public int CurrentTurn { get { return TheBoard.Count(x => x != 0); } } 31 | 32 | public static readonly List WinningPlaces = new(); 33 | 34 | public static void CalculateWinningPlaces() 35 | { 36 | 37 | // Horizontal rows 38 | for (byte row=0;row<6;row++){ 39 | 40 | byte rowCol1 = (byte)(row * 7); 41 | byte rowColEnd = (byte)((row + 1) * 7 - 1); 42 | byte checkCol = rowCol1; 43 | while (checkCol <= rowColEnd-3) 44 | { 45 | WinningPlaces.Add(new int[] { 46 | checkCol, 47 | (byte)(checkCol + 1), 48 | (byte)(checkCol + 2), 49 | (byte)(checkCol + 3) 50 | }); 51 | checkCol++; 52 | } 53 | 54 | } 55 | 56 | // Vertical Columns 57 | for (byte col = 0; col < 7; col++) 58 | { 59 | 60 | byte colRow1 = col; 61 | byte colRowEnd = (byte)(35+col); 62 | byte checkRow = colRow1; 63 | while (checkRow <= 14+col) 64 | { 65 | WinningPlaces.Add(new int[] { 66 | checkRow, 67 | (byte)(checkRow + 7), 68 | (byte)(checkRow + 14), 69 | (byte)(checkRow + 21) 70 | }); 71 | checkRow+=7; 72 | } 73 | 74 | } 75 | 76 | // forward slash diagonal "/" 77 | for (byte col = 0; col < 4; col++) 78 | { 79 | 80 | // starting column must be 0-3 81 | byte colRow1 = (byte)(21 + col); 82 | byte colRowEnd = (byte)(35 + col); 83 | byte checkPos = colRow1; 84 | while (checkPos <= colRowEnd) 85 | { 86 | WinningPlaces.Add(new int[] { 87 | checkPos, 88 | (byte)(checkPos - 6), 89 | (byte)(checkPos - 12), 90 | (byte)(checkPos - 18) 91 | }); 92 | checkPos += 7; 93 | } 94 | 95 | } 96 | 97 | // back slash diaganol "\" 98 | for (byte col = 0; col < 4; col++) 99 | { 100 | 101 | // starting column must be 0-3 102 | byte colRow1 = (byte)(0 + col); 103 | byte colRowEnd = (byte)(14 + col); 104 | byte checkPos = colRow1; 105 | while (checkPos <= colRowEnd) 106 | { 107 | WinningPlaces.Add(new int[] { 108 | checkPos, 109 | (byte)(checkPos + 8), 110 | (byte)(checkPos + 16), 111 | (byte)(checkPos + 24) 112 | }); 113 | checkPos += 7; 114 | } 115 | 116 | } 117 | 118 | 119 | } 120 | 121 | /// 122 | /// Check the state of the board for a winning scenario 123 | /// 124 | /// 0 - no winner, 1 - player 1 wins, 2 - player 2 wins, 3 - draw 125 | public WinState CheckForWin() 126 | { 127 | 128 | // Exit immediately if less than 7 pieces are played 129 | if (TheBoard.Count(x => x != 0) < 7) return WinState.No_Winner; 130 | 131 | foreach (var scenario in WinningPlaces) 132 | { 133 | 134 | if (TheBoard[scenario[0]] == 0) continue; 135 | 136 | if (TheBoard[scenario[0]] == 137 | TheBoard[scenario[1]] && 138 | TheBoard[scenario[1]] == 139 | TheBoard[scenario[2]] && 140 | TheBoard[scenario[2]] == 141 | TheBoard[scenario[3]]) return (WinState)TheBoard[scenario[0]]; 142 | 143 | } 144 | 145 | if (TheBoard.Count(x => x != 0) == 42) return WinState.Tie; 146 | 147 | return WinState.No_Winner; 148 | 149 | } 150 | 151 | /// 152 | /// Takes the current turn and places a piece in the 0-indexed column requested 153 | /// 154 | /// 0-indexed column to place the piece into 155 | /// The final array index where the piece resides 156 | public byte PlayPiece(int column) 157 | { 158 | 159 | // Check for a current win 160 | if (CheckForWin() != 0) throw new ArgumentException("Game is over"); 161 | 162 | // Check the column 163 | if (TheBoard[column] != 0) throw new ArgumentException("Column is full"); 164 | 165 | // Drop the piece in 166 | var landingSpot = column; 167 | for (var i=column;i<42;i+=7) 168 | { 169 | if (TheBoard[landingSpot + 7] != 0) break; 170 | landingSpot = i; 171 | } 172 | 173 | TheBoard[landingSpot] = PlayerTurn; 174 | 175 | return ConvertLandingSpotToRow(landingSpot); 176 | 177 | } 178 | 179 | public List TheBoard { get; private set; } = new List(new int[42]); 180 | 181 | public void ResetBoard() { 182 | TheBoard = new List(new int[42]); 183 | } 184 | 185 | private byte ConvertLandingSpotToRow(int landingSpot) 186 | { 187 | 188 | return (byte)(Math.Floor(landingSpot / (decimal)7) + 1); 189 | 190 | } 191 | 192 | } -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Program.cs: -------------------------------------------------------------------------------- 1 | using ConnectFour; 2 | using ConnectFour.Components; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | // Add services to the container. 7 | builder.Services.AddRazorComponents() 8 | .AddInteractiveServerComponents(); 9 | builder.Services.AddSingleton(); 10 | 11 | var app = builder.Build(); 12 | 13 | // Configure the HTTP request pipeline. 14 | if (!app.Environment.IsDevelopment()) 15 | { 16 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 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 | 23 | app.UseStaticFiles(); 24 | app.UseAntiforgery(); 25 | 26 | app.MapRazorComponents() 27 | .AddInteractiveServerRenderMode(); 28 | 29 | app.Run(); 30 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:16315", 7 | "sslPort": 44390 8 | } 9 | }, 10 | "profiles": { 11 | "http": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "http://localhost:5007", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "https": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": true, 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "applicationUrl": "https://localhost:7000;http://localhost:5007", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 34 | "environmentVariables": { 35 | "ASPNETCORE_ENVIRONMENT": "Development" 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/wwwroot/app.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 3 | } 4 | 5 | a, .btn-link { 6 | color: #006bb7; 7 | } 8 | 9 | .btn-primary { 10 | color: #fff; 11 | background-color: #1b6ec2; 12 | border-color: #1861ac; 13 | } 14 | 15 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 16 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 17 | } 18 | 19 | .content { 20 | padding-top: 1.1rem; 21 | } 22 | 23 | h1:focus { 24 | outline: none; 25 | } 26 | 27 | .valid.modified:not([type=checkbox]) { 28 | outline: 1px solid #26b050; 29 | } 30 | 31 | .invalid { 32 | outline: 1px solid #e50000; 33 | } 34 | 35 | .validation-message { 36 | color: #e50000; 37 | } 38 | 39 | .blazor-error-boundary { 40 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 41 | padding: 1rem 1rem 1rem 3.7rem; 42 | color: white; 43 | } 44 | 45 | .blazor-error-boundary::after { 46 | content: "An error has occurred." 47 | } 48 | 49 | .darker-border-checkbox.form-check-input { 50 | border-color: #929292; 51 | } 52 | -------------------------------------------------------------------------------- /5-blazor/1-complete/ConnectFour/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/1-complete/ConnectFour/wwwroot/favicon.png -------------------------------------------------------------------------------- /5-blazor/img/1-NewTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/img/1-NewTemplate.png -------------------------------------------------------------------------------- /5-blazor/img/2-Board-Step1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/img/2-Board-Step1.png -------------------------------------------------------------------------------- /5-blazor/img/2-Board-Step2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/img/2-Board-Step2.png -------------------------------------------------------------------------------- /5-blazor/img/2-Board-Step3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/img/2-Board-Step3.png -------------------------------------------------------------------------------- /5-blazor/img/2-board-drop.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/img/2-board-drop.gif -------------------------------------------------------------------------------- /5-blazor/img/3-Board-ErrorHandler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/img/3-Board-ErrorHandler.png -------------------------------------------------------------------------------- /5-blazor/img/3-Board-Step1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/img/3-Board-Step1.png -------------------------------------------------------------------------------- /5-blazor/img/3-Board-Step2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/img/3-Board-Step2.png -------------------------------------------------------------------------------- /5-blazor/img/4-Board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/5-blazor/img/4-Board.png -------------------------------------------------------------------------------- /6-publish/images/azure-customer-agreement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/6-publish/images/azure-customer-agreement.png -------------------------------------------------------------------------------- /6-publish/images/azure-start-free.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/6-publish/images/azure-start-free.png -------------------------------------------------------------------------------- /6-publish/images/create-new-app-service.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/6-publish/images/create-new-app-service.png -------------------------------------------------------------------------------- /6-publish/images/hosting-plan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/6-publish/images/hosting-plan.png -------------------------------------------------------------------------------- /6-publish/images/publish-new-app-service.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/6-publish/images/publish-new-app-service.png -------------------------------------------------------------------------------- /6-publish/images/sign-in-azure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/6-publish/images/sign-in-azure.png -------------------------------------------------------------------------------- /6-publish/images/solution-explorer-publish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/6-publish/images/solution-explorer-publish.png -------------------------------------------------------------------------------- /6-publish/images/specific-target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/6-publish/images/specific-target.png -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project has adopted the code of conduct defined by the Contributor Covenant 4 | to clarify expected behavior in our community. 5 | For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) .NET Foundation. All rights reserved. 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 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). 40 | 41 | -------------------------------------------------------------------------------- /images/intro-thumbnail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/images/intro-thumbnail.jpg -------------------------------------------------------------------------------- /images/what-is-dotnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/intro-to-dotnet-web-dev/8b4bf9bc410c4b41bbbe5285cd676da7828d1d00/images/what-is-dotnet.png --------------------------------------------------------------------------------