Skip to content

hotnunstar/code-maze-dot-net-api

Repository files navigation

Company Employees API

A RESTful Web API project built with ASP.NET Core 10, following the Ultimate ASP.NET Core Web API course by CodeMaze.

🚧 Development Status

This project is currently in development and implements features up to Part 15 of the course.

📚 About

This is a comprehensive Web API solution demonstrating modern ASP.NET Core development practices, including:

  • Layered Architecture - Separation of concerns across multiple projects
  • Repository Pattern - Data access abstraction
  • Service Layer - Business logic implementation
  • Entity Framework Core - ORM for database operations
  • AutoMapper - Object-to-object mapping
  • NLog - Structured logging
  • Content Negotiation - XML, JSON, and CSV output formatters
  • Action Filters - Request validation
  • Global Error Handling - Centralized exception management

🏗️ Solution Structure

CompanyEmployees/
├── CompanyEmployees              # Main Web API project
├── CompanyEmployees.Presentation # Controllers and presentation layer
├── Service                       # Business logic implementation
├── Service.Contracts            # Service interfaces
├── Repository                   # Data access layer
├── Contracts                    # Repository interfaces
├── Entities                     # Domain models and configuration
├── Shared                       # DTOs and shared utilities
└── LoggerService                # Logging implementation

🛠️ Technologies

  • .NET 10
  • ASP.NET Core Web API
  • Entity Framework Core 10.0.1
  • SQL Server
  • AutoMapper 16.0.0
  • NLog 6.1.0
  • Custom CSV Output Formatter

🚀 Getting Started

Prerequisites

  • .NET 10 SDK
  • SQL Server
  • Visual Studio 2022 or later (or VS Code)

Installation

  1. Clone the repository

    git clone [repository-url]
    cd CompanyEmployees
  2. Update the connection string in CompanyEmployees/appsettings.json

    "ConnectionStrings": {
      "sqlConnection": "Server=YOUR_SERVER; Database=CompanyEmployees; Trusted_Connection=true; TrustServerCertificate=true;"
    }
  3. Apply database migrations

    dotnet ef database update --project CompanyEmployees
  4. Run the application

    dotnet run --project CompanyEmployees

    The API will be available at https://localhost:5001 (or the port specified in launchSettings.json).

📖 Features Implemented (Up to Part 15)

  • ✅ Onion Architecture setup
  • ✅ Dependency Injection configuration
  • ✅ Logger service integration with NLog
  • ✅ Repository pattern implementation
  • ✅ SQL Server configuration with EF Core
  • ✅ GET, POST, PUT, DELETE operations
  • ✅ Content negotiation (JSON, XML, CSV)
  • ✅ Custom CSV output formatter
  • ✅ Global error handling middleware
  • ✅ AutoMapper configuration for DTOs
  • ✅ Action filters for validation
  • ✅ Model validation with data annotations
  • ✅ Asynchronous operations
  • ✅ HTTP PATCH with JSON Patch Document
  • ✅ Company and Employee management endpoints

🔌 API Endpoints

Companies

  • GET /api/companies - Get all companies
  • GET /api/companies/{id} - Get company by ID
  • POST /api/companies - Create a new company
  • PUT /api/companies/{id} - Update a company
  • DELETE /api/companies/{id} - Delete a company

Employees

  • GET /api/companies/{companyId}/employees - Get all employees for a company
  • GET /api/companies/{companyId}/employees/{id} - Get employee by ID
  • POST /api/companies/{companyId}/employees - Create a new employee
  • PUT /api/companies/{companyId}/employees/{id} - Update an employee
  • PATCH /api/companies/{companyId}/employees/{id} - Partially update an employee
  • DELETE /api/companies/{companyId}/employees/{id} - Delete an employee

Content Negotiation

The API supports multiple response formats:

  • JSON (default): Accept: application/json
  • XML: Accept: application/xml
  • CSV: Accept: text/csv (for Company endpoints)

🏛️ Architecture

This project follows the Onion Architecture pattern with clear separation of concerns:

  • CompanyEmployees - Entry point, configures services and middleware
  • CompanyEmployees.Presentation - API controllers
  • Service / Service.Contracts - Business logic layer
  • Repository / Contracts - Data access layer
  • Entities - Domain models and EF Core configuration
  • Shared - DTOs for data transfer
  • LoggerService - Cross-cutting logging concern

📝 License

This is a learning project following the CodeMaze Ultimate ASP.NET Core Web API course.

🔗 Resources


Note: This project is for educational purposes and is actively being developed as I progress through the course.

About

Project solution developed during Code Maze Ultimate ASP.NET Core Web API Course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages