using esoft.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;

namespace esoft.Class
{
    /// <summary>
    /// Получение контекста таблиц БД
    /// </summary>
    public class ActualContext
    {
        readonly List<User> users;
        readonly List<Executor> executor;
        readonly List<Manager> manager;
        readonly List<esoft.Entities.Task> tasks;

        public List<User> Users
        {
            get { return users; }         
        }
        public List<Executor> Executor 
        {
            get {  return executor; } 
        }
        public List <Manager> Manager
        {
            get { return manager; }
        }
        public List<esoft.Entities.Task> Tasks
        {
            get { return esoftEntities.GetContext().Task.ToList(); }
        }

        /// <summary>
        /// Заполнение контекстом полей
        /// </summary>
        public ActualContext()
        {
            try
            {
                users = esoftEntities.GetContext().User.ToList();
                executor = esoftEntities.GetContext().Executor.ToList();
                manager = esoftEntities.GetContext().Manager.ToList();
            }
            catch
            {
                MessageBox.Show("Ошибка подключчения",
                    "Проверте подключение к интернету", 
                    MessageBoxButton.OK, 
                    MessageBoxImage.Error);
            }
        }

    }
}
