using ShipyardContracts.BindingModels; using ShipyardContracts.ViewModels; using ShipyardDataModels.Models; namespace ShipyardListImplement.Models { public class Ship : IShipModel { public int Id { get; private set; } public string ShipName { get; private set; } = string.Empty; public double Price { get; private set; } public Dictionary ShipDetails { get; private set; } = new Dictionary(); public static Ship? Create(ShipBindingModel? model) { if (model == null) { return null; } return new Ship() { Id = model.Id, ShipName = model.ShipName, Price = model.Price, ShipDetails = model.ShipDetails }; } public void Update(ShipBindingModel? model) { if (model == null) { return; } ShipName = model.ShipName; Price = model.Price; ShipDetails = model.ShipDetails; } public ShipViewModel GetViewModel => new() { Id = Id, ShipName = ShipName, Price = Price, ShipDetails = ShipDetails }; } }