using ComputerHardwareStoreContracts.BindingModels; using ComputerHardwareStoreContracts.ViewModels; using ComputerHardwareStoreDataModels.Models; using System.ComponentModel.DataAnnotations; namespace ComputerHardwareStoreDatabaseImplement.Models { public class Comment : ICommentModel { public int Id { get; set; } [Required] public DateTime Date { get; set; } [Required] public string Text { get; set; } = string.Empty; [Required] public int BuildId { get; set; } public virtual Build Build { get; set; } = new(); public static Comment? Create(CommentBindingModel model) { if (model == null) { return null; } return new() { Id = model.Id, Date = model.Date, Text = model.Text, BuildId = model.BuildId, }; } public void Update(CommentBindingModel model) { if (model == null) { return; } Text = model.Text; } public CommentViewModel GetViewModel => new() { Id = Id, Date = Date, Text = Text, }; } }