using AvaloniaApplicationTest.ViewModels;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AvaloniaApplicationTest.Models
{
    public partial class Hotel
    {
        public String CountryName
        {
            get
            {
                foreach (var i in MainWindowViewModel.myConnection.Countries)
                {
                    if (i.Code == CountryCode)
                        return i.Name;
                }
                return "Отсутствует";
            }
        }

        public String Stars
        {
            get
            {
                switch (CountOfStars)
                {
                    case 1:
                        return "★☆☆☆☆";
                    case 2:
                        return "★★☆☆☆";
                    case 3:
                        return "★★★☆☆";
                    case 4:
                        return "★★★★☆";
                    case 5:
                        return "★★★★★";
                    default:
                        break;
                }
                return "☆☆☆☆☆";
            }
        }

        public int CountTours
        {
            get
            {
                int tours = MainWindowViewModel.myConnection.Tours.Include(x => x.Hotels).Where(x => x.Hotels.Where(x => x.Name == this.Name).Count() != 0).Count();
                return tours;
            }
        }
    }
}
