using RouteGuideContracts.BindingModels; using RouteGuideContracts.ViewModels; using RouteGuideDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RouteGuideDatabaseImplements.Models { public class Stop : IStopModel { public int Id { get; private set; } [Required] public string Name { get; private set; } = string.Empty; [ForeignKey("StopId")] public virtual List RoutesStops { get; set; } = new(); public static Stop? Create(StopBindingModel model) { if (model == null) { return null; } return new Stop() { Id = model.Id, Name = model.Name, }; } public static Stop Create(StopViewModel model) { return new Stop { Id = model.Id, Name = model.Name, }; } public void Update(StopBindingModel model) { if (model == null) { return; } Name = model.Name; } public StopViewModel GetViewModel => new() { Id = Id, Name = Name, }; } }