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 Guide : IGuideModel
    {
        public int Id { get; set; }
        [Required]
        public string Surname { get; set; } = string.Empty;
        [Required]
        public string Name { get; set; } = string.Empty;
        public string? Patronymic { get; set; } = string.Empty;
        [Required]
        public int OperatorId { get; private set; }
        public virtual Operator Operator { get; set; }
        [ForeignKey("GuideId")]
        public virtual List<GuideExcursion> GuideExcursions { get; set; } = new();
        public static Guide? Create(GuideBindingModel model)
        {
            if (model == null)
            {
                return null;
            }
            return new Guide()
            {
                Id = model.Id,
                Surname = model.Surname,
                Name = model.Name,
                Patronymic = model.Patronymic,
                OperatorId = model.OperatorId
            };
        }
        public GuideViewModel GetViewModel => new()
        {
            Id = Id,
            Surname = Surname,
            Name = Name,
            Patronymic = Patronymic,
            OperatorId = OperatorId,
        };
    }
}