using ShipyardContracts.ViewModels; using ShipyardDataModels.Models; using ShipyardContracts.BindingModels; 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 ShipComponents { 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, ShipComponents = model.ShipComponents }; } public void Update(ShipBindingModel? model) { if (model == null) { return; } ShipName = model.ShipName; Price = model.Price; ShipComponents = model.ShipComponents; } public ShipViewModel GetViewModel => new() { Id = Id, ShipName = ShipName, Price = Price, ShipComponents = ShipComponents }; } }