Skip to content

informatixs/materialmanagementapp

Repository files navigation

test

test01 # Material Management Application

A comprehensive ASP.NET Core 8.0 MVC application for managing materials and categories with user authentication and role-based authorization.

Features

  • User Authentication: ASP.NET Core Identity with registration and login
  • Role-Based Authorization: Admin, Manager, and User roles
  • CRUD Operations: Full Create, Read, Update, Delete functionality
  • Entity Framework Core: Code-first approach with migrations
  • Responsive Design: Bootstrap-based UI
  • Docker Support: Multi-stage Dockerfile for containerization
  • Database Seeding: Automatic role and admin user creation

Technologies Used

  • Framework: ASP.NET Core 8.0 MVC
  • Database: Entity Framework Core with SQL Server
  • Authentication: ASP.NET Core Identity
  • Frontend: Razor Views, Bootstrap 5
  • Containerization: Docker
  • Version Control: Git

Prerequisites

Quick Start

1. Clone the Repository

git clone https://github.com/informatixs/materialmanagementapp.git
cd materialmanagementapp

2. Configure Database

Update the connection string in appsettings.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=MaterialManagementDB;Trusted_Connection=True;"
  }
}

For SQLite (cross-platform):

{
  "ConnectionStrings": {
    "DefaultConnection": "Data Source=MaterialManagement.db"
  }
}

3. Apply Migrations

dotnet ef database update

4. Run the Application

dotnet run

Navigate to: https://localhost:5001

Default Credentials

After running the application for the first time:

Project Structure

MaterialManagement/
├── Controllers/
│   ├── CategoriesController.cs
│   ├── HomeController.cs
│   └── MaterialsController.cs
├── Data/
│   ├── ApplicationDbContext.cs
│   └── SeedData.cs
├── Models/
│   ├── Category.cs
│   └── Material.cs
├── Views/
│   ├── Categories/
│   ├── Materials/
│   ├── Home/
│   └── Shared/
├── wwwroot/
│   ├── css/
│   ├── js/
│   └── lib/
├── appsettings.json
├── Program.cs
├── Dockerfile
└── .gitignore

Docker Deployment

Build Docker Image

docker build -t materialmanagement .

Run Container

docker run -p 8080:8080 -p 8081:8081 materialmanagement

Access the app at: http://localhost:8080

Database Schema

Categories Table

  • CategoryId (PK)
  • Name
  • Description

Materials Table

  • MaterialId (PK)
  • Name
  • Description
  • Price
  • Quantity
  • CategoryId (FK)

Relationships

  • One Category can have many Materials (One-to-Many)

Common Commands

Entity Framework

# Create a new migration
dotnet ef migrations add MigrationName

# Update database
dotnet ef database update

# Remove last migration
dotnet ef migrations remove

# Drop database
dotnet ef database drop

Run Application

# Standard run
dotnet run

# With hot reload
dotnet watch run

# Specific environment
dotnet run --environment Production

Build and Publish

# Build project
dotnet build

# Publish for deployment
dotnet publish -c Release -o ./publish

Development Workflow

  1. Create a new feature branch

    git checkout -b feature/your-feature-name
  2. Make changes and test

    dotnet watch run
  3. Commit changes

    git add .
    git commit -m "Add feature: description"
  4. Push to GitHub

    git push origin feature/your-feature-name
  5. Create Pull Request on GitHub

Learning Resources

For a detailed step-by-step tutorial on building this application from scratch, see TUTORIAL.md

What You'll Learn

  • ASP.NET Core MVC fundamentals
  • Entity Framework Core with Code First
  • Identity framework implementation
  • CRUD operations
  • Database relationships
  • Docker containerization
  • Git version control

Troubleshooting

Issue: LocalDB not available (macOS/Linux)

Solution: Switch to SQLite

  1. Remove SQL Server package:

    dotnet remove package Microsoft.EntityFrameworkCore.SqlServer
  2. Add SQLite package:

    dotnet add package Microsoft.EntityFrameworkCore.Sqlite
  3. Update Program.cs:

    options.UseSqlite(connectionString)

Issue: Port already in use

Solution: Change port

dotnet run --urls "http://localhost:5005"

Issue: Migration errors

Solution: Reset migrations

dotnet ef database drop
dotnet ef migrations remove
dotnet ef migrations add InitialCreate
dotnet ef database update

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

This project is licensed for educational purposes.

Authors

  • Tutorial created for ASP.NET Core training

Acknowledgments

  • ASP.NET Core Team
  • Entity Framework Core Team
  • Bootstrap Team

Support

For issues and questions:


Happy Coding! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •