using Reconstruction;

namespace Reconstruction.Functions
{ 
    public static class Display
    {
        public static void ShowUserList()
        {
            Console.WriteLine("Login  |" + "  Lastname  |" + "  Firstname  |" + "  Middlename ");
            foreach (User s in Service.UserCollection)
            {
                Console.WriteLine(s.Login + ' ' + s.Lastname + ' ' + s.Firstname + ' ' + s.Middlename);
            }

            Console.ReadKey();  

        }



        public static void ShowProfileData()
        {
            Console.WriteLine("User Name: "     + Service.LoggedUser.Login 
                          + "\nFirst name: "    + Service.LoggedUser.Firstname 
                          + "\nSurname: "       + Service.LoggedUser.Lastname 
                          + "\nPatronimic: "    + Service.LoggedUser.Middlename 
                          + "\nPhone: "         + Service.LoggedUser.Phone 
                          + "\nTasks: ");
            Service.db.Tasks.Where(t => t.AccUserId == Service.LoggedUser.Id).ToList().ForEach(t => global::System.Console.Write(t.Title + " "));
        
            Console.ReadKey();
        }


        public static void ShowAvailableTask()
        {

            Console.WriteLine("Title:");
            Service.db.Tasks.Where  (t => t.StatusId == 1).ToList()
                            .ForEach(t => global::System.Console.Write("\nTitle: "       + t.Title       + 
                                                                       "\nDescription: " + t.Description + 
                                                                       "\nCreated by " + Service.db.Users.Where(u => t.CreatorUserId == u.Id).DefaultIfEmpty());

            Console.ReadKey();
        }

    }
}
