using System.Collections.Generic; using System.Linq; using YourNamespace.Entities; using YourNamespace.Repositories; namespace YourNamespace.Repositories.Implementations { public class PlaneRepository : IPlaneRepository { private readonly List _planes = new List(); private int _nextId = 1; public IEnumerable ReadPlanes() { return _planes; } public Plane ReadPlaneById(int id) { return _planes.FirstOrDefault(p => p.Id == id); } public void CreatePlane(Plane plane) { var newPlane = Plane.CreateEntity(_nextId++, plane.Model, plane.Capacity); _planes.Add(newPlane); } public void UpdatePlane(Plane plane) { var existingPlane = _planes.FirstOrDefault(p => p.Id == plane.Id); if (existingPlane != null) { var updatedPlane = Plane.CreateEntity(existingPlane.Id, plane.Model, plane.Capacity); _planes.Remove(existingPlane); _planes.Add(updatedPlane); } } public void DeletePlane(int id) { var planeToRemove = _planes.FirstOrDefault(p => p.Id == id); if (planeToRemove != null) { _planes.Remove(planeToRemove); } } } }