Skip to content

Repository files navigation

Flight Booking System

A simple flight management solution built with ASP.NET Core Web API on the backend and a .NET console client on the front end. The API exposes full CRUD operations for flights, backed by SQL Server stored procedures, and the console client consumes those endpoints over HTTP.

Project Structure

Flight Booking System/
├── Flight Booking System/          # ASP.NET Core 8 Web API
│   ├── Controllers/
│   │   └── FlightController.cs     # REST endpoints for flight CRUD operations
│   ├── Data/
│   │   └── DBConnectionFactory.cs  # Creates SqlConnection instances from config
│   ├── Models/
│   │   └── Flight.cs               # Flight entity
│   ├── Repository/
│   │   ├── IFlightRepository.cs
│   │   └── FlightRepository.cs     # ADO.NET data access (calls stored procedures)
│   ├── Services/
│   │   ├── IFlightServices.cs
│   │   └── FlightServices.cs       # Business logic layer
│   ├── menus/
│   │   └── menu.cs                 # Console-based menu for direct repository access
│   ├── appsettings.json            # Configuration (connection string, logging)
│   └── Program.cs                  # App startup / DI configuration
│
├── FlightBookingClient/            # .NET Framework console client
│   ├── MenuHandler/
│   │   └── Menu.cs                 # Interactive console menu
│   ├── Model/
│   │   └── Flight.cs               # Client-side Flight DTO
│   ├── Services/
│   │   └── FlightServices.cs       # HttpClient wrapper for calling the API
│   └── Program.cs                  # Entry point
│
├── SQLScripts/
│   └── FlightDB.sql                # Database, table, and stored procedure definitions
│
└── Flight Booking System.slnx      # Visual Studio solution file

Features

  • View all flights — retrieve every active flight, ordered by departure time
  • Search by Flight ID — fetch a single flight's details
  • Add a flight — insert a new flight with validation (non-empty fields, distinct source/destination, future departure time, positive price, non-negative seats)
  • Update a flight — modify an existing flight's details
  • Delete a flight — soft-delete (flight is deactivated, not physically removed, preserving data for audit)
  • Duplicate prevention — flight numbers must be unique among active flights
  • Console client — a standalone menu-driven client that talks to the API over HTTP

Tech Stack

Layer Technology
API ASP.NET Core 8 (Minimal hosting model)
Data access ADO.NET (Microsoft.Data.SqlClient) + stored procedures
Database SQL Server
API documentation Swagger / Swashbuckle
Client .NET Framework 4.7.2 console app (HttpClient)

Prerequisites

  • .NET 8 SDK
  • .NET Framework 4.7.2 Developer Pack (for the console client)
  • SQL Server (LocalDB, Express, or a full instance)
  • Visual Studio 2022 (recommended) or any editor that supports .slnx solutions

Getting Started

1. Clone the repository

git clone https://github.com/mohanish-kv/Flight-Booking-System.git
cd Flight-Booking-System

2. Set up the database

Run the script in SQLScripts/FlightDB.sql against your SQL Server instance. It will:

  • Create the FlightDB database
  • Create the Flights table
  • Seed a handful of sample flights
  • Create the stored procedures used by the API:
    • sp_GetAllFlights
    • sp_GetFlightById
    • sp_InsertFlight
    • sp_UpdateFlight
    • sp_DeleteFlight (soft delete)
    • sp_SearchFlights (filter by source city, destination city, and/or travel date)
sqlcmd -S <your_server> -i SQLScripts/FlightDB.sql

3. Configure the connection string

Update Flight Booking System/appsettings.json (and appsettings.Development.json) with your SQL Server instance name:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=YOUR_SERVER;Database=FlightDB;Trusted_Connection=True;TrustServerCertificate=True"
  }
}

⚠️ These files currently contain a hardcoded server name for local development. Update them (or better, move secrets to dotnet user-secrets / environment variables) before deploying.

4. Run the API

cd "Flight Booking System"
dotnet run

The API starts on http://localhost:5251 by default, and the Swagger UI opens automatically at /swagger for exploring and testing the endpoints.

5. Run the console client (optional)

The client targets .NET Framework and is set up to be run from Visual Studio, or via msbuild + the compiled executable:

cd FlightBookingClient
# Build with Visual Studio or msbuild, then run the resulting FlightBookingClient.exe

By default the client points at http://localhost:5251/, so make sure the API is running first.

API Endpoints

Because the controller uses action-based routing (api/[controller]/[action]), each endpoint includes the action name:

Method Route Description
GET /api/Flight/GetAllDetails Get all active flights
GET /api/Flight/GetFlightById/{FlightID} Get a single flight by ID
POST /api/Flight/Post Add a new flight (query params)
PUT /api/Flight/Put Update an existing flight (JSON body)
DELETE /api/Flight/DeleteFlight Delete a flight (FlightId query param)

Note: The bundled console client currently calls routes like api/flight/{id} (attribute-style), which don't match the API's action-based routes above. If you're wiring the client up against the API, update the client's FlightServices.cs to use the correct action names, or switch the controller to attribute routing.

Known Issues / Housekeeping

  • Connection strings in appsettings.json are checked into source control — replace with environment-specific configuration before any real deployment.
  • The console client's request URLs don't fully match the API's route names (see above).
  • There's a stray top-level Flight.cs and an empty FlightBookingClient/models/Flight.cs left over from earlier iterations; safe to remove once confirmed unused.
  • sp_SearchFlights is defined in the database but not yet wired up to a controller endpoint.

License

No license has been specified for this project yet. Add a LICENSE file if you intend to open-source it.

About

A Flight Booking Management System built with ASP.NET Core Web API, ADO.NET, SQL Server, and a Console Client using HttpClient. It demonstrates REST APIs, CRUD operations, stored procedures, dependency injection, JSON serialization, layered architecture, and API consumption.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages