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 TravelCompanyDataModels.Models.TouristModels;
using TravelCompanyContracts.BindingModels.TouristBindingModels;
using TravelCompanyContracts.ViewModels.TouristViewModels;

namespace TravelCompanyDatabaseImplement.Models.TouristModel
{
    public class Excursion : IExcursionModel
    {
        public int Id { get; set; }
        [Required]
        public string ExcursionName { get; set; } = string.Empty;
        [Required]
        public string ExcursionDescrition { get; set; } = string.Empty;
        [Required]
        public int Duration { get; set; }
        [Required]
        public int TouristId { get; set; }
        public virtual Tourist Tourist { get; set; }
        [ForeignKey("ExcursionId")]
        public virtual List<Place> Places { get; set; } = new();
        [ForeignKey("ExcursionId")]
        public virtual List<ExcursionTravel> ExcursionTravels { get; set; } = new();
        [ForeignKey("ExcursionId")]
        public virtual List<GuideExcursion> GuideExcursions { get; set; } = new();

        public static Excursion? Create(ExcursionBindingModel model)
        {
            if (model == null)
            {
                return null;
            }
            return new Excursion()
            {
                Id = model.Id,
                ExcursionName = model.ExcursionName,
                ExcursionDescrition = model.ExcursionDescrition,
                Duration = model.Duration,
                TouristId = model.TouristId
            };
        }
        public void Update(ExcursionBindingModel model)
        {
            if (model == null)
            {
                return;
            }
            ExcursionName = model.ExcursionName;
            ExcursionDescrition = model.ExcursionDescrition;
            Duration = model.Duration;
        }
        public ExcursionViewModel GetViewModel => new()
        {
            Id = Id,
            ExcursionName = ExcursionName,
            ExcursionDescrition = ExcursionDescrition,
            Duration = Duration,
            TouristId = TouristId
        };
    }
}