using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.ViewModels; using TravelAgencyDataModels.Models; namespace TravelAgencyDatabaseImplement.Models { public class Guide : IGuideModel { public int Id { get; set; } [Required] public string GuideFIO { get; set; } = string.Empty; [Required] public string Email { get; set; } = string.Empty; [Required] public string PhoneNumber { get; set; } = string.Empty; [ForeignKey("GuideId")] public virtual List Trips { get; set; } = new(); [ForeignKey("GuideId")] public virtual List ExcursionGroups { get; set; } = new(); public static Guide? Create(GuideBindingModel? model) { if (model == null) { return null; } return new Guide() { Id = model.Id, GuideFIO = model.GuideFIO, Email = model.Email, PhoneNumber = model.PhoneNumber }; } public void Update(GuideBindingModel? model) { if (model == null) { return; } GuideFIO = model.GuideFIO; Email = model.Email; PhoneNumber = model.PhoneNumber; } public GuideViewModel GetViewModel => new() { Id = Id, GuideFIO = GuideFIO, Email = Email, PhoneNumber = PhoneNumber }; } }