using System.Collections.Generic;
public bool IsInStock { get; set; }
public PriceInfo PriceInfo { get; set; }
public City DepartureCity { get; set; }
public DateTime DepartureDate { get; set; }
public decimal Price { get; set; }
public string Value { get; set; }
public static void Main()
List<Product> products = new List<Product>
new Product { IsInStock = true, PriceInfo = new PriceInfo { Price = 259 }, DepartureCity = new City { Value = "TLS" }, DepartureDate = new DateTime(2024, 11, 12) },
new Product { IsInStock = true, PriceInfo = new PriceInfo { Price = 259 }, DepartureCity = new City { Value = "NTE" }, DepartureDate = new DateTime(2024, 11, 11) },
new Product { IsInStock = true, PriceInfo = new PriceInfo { Price = 259 }, DepartureCity = new City { Value = "TLS" }, DepartureDate = new DateTime(2024, 11, 25) },
new Product { IsInStock = true, PriceInfo = new PriceInfo { Price = 259 }, DepartureCity = new City { Value = "TLS" }, DepartureDate = new DateTime(2024, 11, 26) },
new Product { IsInStock = true, PriceInfo = new PriceInfo { Price = 259 }, DepartureCity = new City { Value = "NTE" }, DepartureDate = new DateTime(2024, 11, 13) },
new Product { IsInStock = true, PriceInfo = new PriceInfo { Price = 259 }, DepartureCity = new City { Value = "NTE" }, DepartureDate = new DateTime(2024, 11, 25) },
City defaultDepartureCity = new City { Value = "PAR"};
Product minProduct = products.MinBy(element =>
element.DepartureCity.Value != defaultDepartureCity?.Value,
Console.WriteLine($"Produit sélectionné : {minProduct.PriceInfo.Price} - {minProduct.DepartureCity.Value} - {minProduct.DepartureDate.ToShortDateString()}");