
using Microsoft.Data.SqlClient;

namespace Models;

public class Vehicle
{
    public required long Id { get; set; }
    public required string Brand { get; set; }
    public required string Model { get; set; }
    public required string LicencePlate { get; set; }
    public required string Category { get; set; }
    public required decimal PricePerDay { get; set; }
    public required string Location { get; set; }
    public required string LocationAddress { get; set; }
    public required string Status { get; set; }

    public static Vehicle FromReader(SqlDataReader reader)
    {
        return new Vehicle
        {
            Id = (long)reader["id"],
            Brand = (string)reader["brand"],
            Model = (string)reader["model"],
            LicencePlate = (string)reader["licensePlate"],
            Category = (string)reader["category"],
            PricePerDay = (decimal)reader["pricePerDay"],
            Location = (string)reader["location"],
            LocationAddress = (string)reader["locationAddress"],
            Status = (string)reader["status"]
        };
    }
}