|
1 | 1 | # SampleMvcCRUD |
2 | | -An Asp.Net MVC Application to demonstrate multiple ways of implementing a simple maintenance (CRUD) user interface |
3 | 2 |
|
4 | | -[]([main_mwhsampleweb.yml](https://github.com/markhazleton/SampleMvcCRUD/blob/main/.github/workflows/main_mwhsampleweb.yml)) |
| 3 | +An ASP.NET Core MVC application demonstrating multiple approaches to implementing a modern, maintainable CRUD (Create, Read, Update, Delete) user interface. This repository is designed as a reference and educational resource for developers interested in best practices for web application architecture, theming, API design, and deployment. |
5 | 4 |
|
6 | | -[]([docker-image.yml](https://github.com/markhazleton/SampleMvcCRUD/blob/main/.github/workflows/docker-image.yml)) |
| 5 | +[](https://github.com/markhazleton/SampleMvcCRUD/actions/workflows/main_mwhsampleweb.yml) |
| 6 | +[](https://github.com/markhazleton/SampleMvcCRUD/actions/workflows/docker-image.yml) |
7 | 7 |
|
8 | | -https://github.com/markhazleton/SampleMvcCRUD/blob/main/.github/workflows/docker-image.yml |
| 8 | +--- |
9 | 9 |
|
| 10 | +## 🌐 Live Demo & Deployments |
10 | 11 |
|
11 | | -For deployments there are multiple approaches: |
| 12 | +- **Windows IIS VM (.NET 9):** [samplecrud.markhazleton.com](https://samplecrud.markhazleton.com/) |
| 13 | +- **Azure App Service (.NET 9, Linux, GitHub Actions):** [mwhsampleweb.azurewebsites.net](https://mwhsampleweb.azurewebsites.net/) |
| 14 | +- **Azure App Service (Docker Image):** [samplecrud.azurewebsites.net](https://samplecrud.azurewebsites.net/) |
| 15 | +- **Docker Hub Image:** [markhazleton/mwhsampleweb](https://hub.docker.com/r/markhazleton/mwhsampleweb) |
12 | 16 |
|
13 | | -1) *current* [GitHub Action](https://github.com/markhazleton/SampleMvcCRUD/actions/workflows/main_mwhsampleweb.yml) with Continuous Integration/Continuous Deployment (CI/CD) to Docker Hub and Azure App Services |
14 | | -1) *current* [GitHub Action](https://github.com/markhazleton/SampleMvcCRUD/actions/workflows/docker-image.yml) to push Docker Image to Docker Hub, then have Azure App Service configured to pull latest version from Docker Hub. |
15 | | -1) [Azure DevOps project](https://dev.azure.com/markhazleton/SampleMvcCRUD) with Continuous Integration/Continuous Deployment (CI/CD) pipelines to Azure App Services |
| 17 | +--- |
16 | 18 |
|
17 | | -Web application is hosted: |
18 | | -- Microsoft Azure Virtual Machine - Windows 2022 IIS - Net 8 [samplecrud.markhazleton.com](https://samplecrud.markhazleton.com/) |
19 | | -- Microsoft Azure AppService .Net 8 Linux Deployed via GitHub Actions [mwhsampleweb.azurewebsites.net](https://mwhsampleweb.azurewebsites.net/) |
20 | | -- Microsoft Azure AppService .Net 8 Linux Image from docker hub [samplecrud.azurewebsites.net](https://samplecrud.azurewebsites.net/) |
21 | | -- Docker Hub Image [markhazleton/mwhsampleweb](https://hub.docker.com/r/markhazleton/mwhsampleweb) |
| 19 | +## 🚀 Project Goals |
22 | 20 |
|
23 | | -## Customization |
| 21 | +- Demonstrate multiple ways to build CRUD UIs in ASP.NET Core MVC |
| 22 | +- Showcase best practices for architecture, testing, and deployment |
| 23 | +- Provide a reference for theming, API design, and modern web techniques |
| 24 | +- Enable easy customization and extension for your own projects |
24 | 25 |
|
25 | | -SampleMvcCrud is open source and you’re encouraged to contribute. |
| 26 | +--- |
26 | 27 |
|
27 | | -## Contributing |
| 28 | +## 🏗️ Features & Architecture |
28 | 29 |
|
29 | | -You can contribute in several ways. |
30 | | -- **Issues:** Provide a detailed report of any bugs you encounter and open an issue on [GitHub](https://github.com/markhazleton/SampleMvcCrud/issues). |
31 | | -- **Documentation:** If you'd like to fix a typo or beef up the docs, you can fork the project, make your changes, and submit a pull request. |
32 | | -- **Code:** Make a fix and submit it as a pull request. |
33 | | -- **Platform:** Right now this has a MVC Web solution, I would love a React/Vue or Mobile version, but my skills are not there yet. |
| 30 | +- **Multiple CRUD Implementations:** |
| 31 | + - Classic MVC Controllers & Views |
| 32 | + - Razor Pages |
| 33 | + - Single Page (JavaScript-driven) UI |
| 34 | + - Pivot Table integration (PivotTable.js) |
| 35 | +- **API-First Design:** |
| 36 | + - RESTful endpoints for Employees and Departments |
| 37 | + - Swagger/OpenAPI documentation ([API Docs](/swagger/)) |
| 38 | +- **Modern UI/UX:** |
| 39 | + - Responsive Bootstrap 5 layout |
| 40 | + - [WebSpark.Bootswatch](https://www.nuget.org/packages/WebSpark.Bootswatch/) theme switcher (light/dark, instant theme change) |
| 41 | + - Bootstrap Icons |
| 42 | + - DataTables integration for advanced tables |
| 43 | +- **Security & Configuration:** |
| 44 | + - Azure Key Vault integration for secrets |
| 45 | + - App Insights telemetry |
| 46 | + - Health checks endpoint (`/health`) |
| 47 | +- **DevOps & CI/CD:** |
| 48 | + - GitHub Actions for build, test, Docker, and Azure deployment |
| 49 | + - Azure DevOps pipeline example |
| 50 | + - Dockerfile for containerized builds |
| 51 | +- **Testing:** |
| 52 | + - Unit tests for domain and repository layers |
| 53 | +- **Extensible Architecture:** |
| 54 | + - Clean separation of Domain, Repository, and Web projects |
| 55 | + - Dependency Injection throughout |
| 56 | + - Example HttpClientFactory usage |
34 | 57 |
|
35 | | -## Author |
| 58 | +--- |
36 | 59 |
|
37 | | -Mark Hazleton |
38 | | -+ https://markhazleton.com |
| 60 | +## 🖌️ Theme Switcher (WebSpark.Bootswatch) |
39 | 61 |
|
40 | | -## Thanks |
41 | | -To the many teachers and developers that post sample code under open source license. |
| 62 | +This app features a dynamic theme switcher using [WebSpark.Bootswatch](https://www.nuget.org/packages/WebSpark.Bootswatch/): |
42 | 63 |
|
43 | | -## Copyright and License |
44 | | -Copyright 2018-2024 Mark Hazleton |
45 | | -Code released under the MIT License. |
| 64 | +- Instantly change the site's look with any [Bootswatch](https://bootswatch.com/) theme |
| 65 | +- Light/dark mode support |
| 66 | +- User preferences are saved in the browser |
| 67 | +- Implemented via `<bootswatch-theme-switcher />` tag helper and JavaScript |
46 | 68 |
|
| 69 | +--- |
47 | 70 |
|
| 71 | +## 🏁 Getting Started |
| 72 | + |
| 73 | +### Prerequisites |
| 74 | + |
| 75 | +- [.NET 9 SDK](https://dotnet.microsoft.com/download) |
| 76 | +- (Optional) [Docker](https://www.docker.com/) |
| 77 | + |
| 78 | +### Run Locally |
| 79 | + |
| 80 | +```pwsh |
| 81 | +# Clone the repository |
| 82 | +git clone https://github.com/markhazleton/SampleMvcCRUD.git |
| 83 | +cd SampleMvcCRUD |
| 84 | +
|
| 85 | +# Restore and run the web app |
| 86 | +dotnet restore |
| 87 | +cd Mwh.Sample.Web |
| 88 | +dotnet run |
| 89 | +``` |
| 90 | + |
| 91 | +Visit [https://localhost:5001](https://localhost:5001) in your browser. |
| 92 | + |
| 93 | +### Run with Docker |
| 94 | + |
| 95 | +```pwsh |
| 96 | +docker build -t mwhsampleweb ./Mwh.Sample.Web |
| 97 | +docker run -p 8080:80 mwhsampleweb |
| 98 | +``` |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## 🧩 Project Structure |
| 103 | + |
| 104 | +- `Mwh.Sample.Web/` - Main ASP.NET Core MVC web app |
| 105 | +- `Mwh.Sample.Domain/` - Domain models and interfaces |
| 106 | +- `Mwh.Sample.Repository/` - Data access and repository pattern |
| 107 | +- `Mwh.Sample.HttpClientFactory/` - HttpClient usage examples |
| 108 | +- `SampleMinimalApi/` - Minimal API example |
| 109 | +- `Mwh.Sample.Domain.Tests/`, `Mwh.Sample.Repository.Tests/` - Unit tests |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## 📚 Key Techniques Demonstrated |
| 114 | + |
| 115 | +- **MVC, Razor Pages, and SPA patterns in one solution** |
| 116 | +- **API-first development with Swagger/OpenAPI** |
| 117 | +- **Modern Bootstrap theming and instant theme switching** |
| 118 | +- **Azure Key Vault for secure configuration** |
| 119 | +- **Health checks and Application Insights** |
| 120 | +- **CI/CD with GitHub Actions and Azure DevOps** |
| 121 | +- **Docker containerization** |
| 122 | +- **Extensible, testable architecture** |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## 📝 Customization & Contribution |
| 127 | + |
| 128 | +SampleMvcCRUD is open source and welcomes contributions! |
| 129 | + |
| 130 | +- **Issues:** [File an issue](https://github.com/markhazleton/SampleMvcCRUD/issues) |
| 131 | +- **Pull Requests:** Fork, branch, and submit your improvements |
| 132 | +- **Documentation:** Help improve this README or add more docs |
| 133 | +- **Feature Ideas:** React/Vue/Mobile UI contributions are welcome |
| 134 | + |
| 135 | +See [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). |
| 136 | + |
| 137 | +--- |
| 138 | + |
| 139 | +## 👤 About the Author |
| 140 | + |
| 141 | +**Mark Hazleton** is a solutions architect and lifelong learner with a passion for building technology that delivers real business value. With extensive experience in both on-premises and cloud-based solutions, Mark has worked with organizations of all sizes—from small business websites to large enterprise projects. He is dedicated to pragmatic, outcome-focused software development, and is an advocate for clear communication, agile practices, and continuous learning. |
| 142 | + |
| 143 | +- [GitHub Profile](https://github.com/markhazleton) |
| 144 | +- [LinkedIn](https://www.linkedin.com/in/markhazleton) |
| 145 | +- [Personal Website](https://markhazleton.com) |
| 146 | + |
| 147 | +*For all questions, contributions, and support, please use the [GitHub repository issues](https://github.com/markhazleton/SampleMvcCRUD/issues) and pull requests. Community participation is welcome and encouraged!* |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +## 🙏 Acknowledgements |
| 152 | + |
| 153 | +Thanks to the open source community, teachers, and developers who share their knowledge and code. |
| 154 | + |
| 155 | +--- |
| 156 | + |
| 157 | +## ⚖️ License |
| 158 | + |
| 159 | +Copyright 2018-2025 Mark Hazleton |
| 160 | +Code released under the MIT License. See [LICENSE](LICENSE). |
0 commit comments