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;
using TravelCompanyContracts.BindingModels.OperatorBindingModels;
using TravelCompanyContracts.ViewModels.OperatorViewModels;
using TravelCompanyDataModels.Models.OperatorModels;

namespace TravelCompanyDatabaseImplement.Models.OperatorModels
{
    public class Tour : ITourModel
    {
        public int Id { get; set; }
        [Required]
        public string TourName { get; set; } = string.Empty;
        [Required]
        public int OperatorId { get; private set; }
        public virtual Operator Operator { get; set; }
        [ForeignKey("TourId")]
        public virtual List<TourTravel> TourTravels { get; set; } = new();

        public static Tour? Create(TourBindingModel model)
        {
            if (model == null)
            {
                return null;
            }
            return new Tour()
            {
                Id = model.Id,
                TourName = model.TourName,
                OperatorId = model.OperatorId,
            };
        }
        public TourViewModel GetViewModel => new()
        {
            Id = Id,
            TourName = TourName,
            OperatorId = OperatorId,
        };
    }
}