using CarShowroomContracts.AbstractModels; using CarShowroomDataModels.Views; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CarShowroomDatabaseStorage.Entities { [Table("make")] [Index(nameof(Name), IsUnique = true)] public class Make : IMake { [Column("make_id")] public int Id { get; private set; } [Required] [Column("make_name")] [MaxLength(50)] public string Name { get; private set; } = string.Empty; public virtual List Models { get; set; } = new(); private Make() { } private Make(IMake make) { Id = make.Id; Name = make.Name; } public static Make? Create(IMake make) { if (make == null) return null; return new Make(make); } public void Update(IMake make) { if (make == null) return; Name = make.Name; } public MakeView GetView() { return new MakeView(this); } } }