using BoxOfficeDashboard.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace BoxOfficeDashboard.ViewModels
{
    public class ViewModel
    {

        private ObservableCollection<Studio> _allStudios;

        public List<List<Studio>> StudiosByYear
        {
            get{
                var groupedStudios = _allStudios.GroupBy(s => s.Year).Select(grp => grp.ToList()).ToList();

                //var results = (from s in _allStudios
                //              group s by s.Year into g
                //              select new {  Year = g.Key }).ToList<Studio>();

                return groupedStudios;
            }

        }

        public ViewModel()
        {
            _allStudios = new ObservableCollection<Studio>();

            //1. Universal
            //2. 20th Century Fox
            //3. Warner Bros.
            //4. Sony/Columbia
            //5. Buena Vista
            //6. Paramount
            //7. Lionsgate

            //2014
            _allStudios.Add(new Studio(2014, "Universal", .116, 738.2, 12));
            _allStudios.Add(new Studio(2014, "20th Century Fox", .181, 1156.7, 14));
            _allStudios.Add(new Studio(2014, "Warner Bros.", .157, 998.9, 20));
            _allStudios.Add(new Studio(2014, "Sony/Columbia", .144, 919.8, 15));
            _allStudios.Add(new Studio(2014, "Buena Vista", .152, 971.2, 13));
            _allStudios.Add(new Studio(2014, "Paramount", .097, 616.0, 11));
            _allStudios.Add(new Studio(2014, "Lionsgate", .047, 300.7, 14));
            _allStudios.Add(new Studio(2014, "Others", .106, 676.5, 0));

            //2013
            _allStudios.Add(new Studio(2013, "Universal", .131, 1433.3, 19));
            _allStudios.Add(new Studio(2013, "20th Century Fox", .097, 1064.2, 19));
            _allStudios.Add(new Studio(2013, "Warner Bros.", .171, 1863.3, 34));
            _allStudios.Add(new Studio(2013, "Sony/Columbia", .105, 1144.6, 20));
            _allStudios.Add(new Studio(2013, "Buena Vista", .157, 1711.0, 17));
            _allStudios.Add(new Studio(2013, "Paramount", .088, 966.9, 16));
            _allStudios.Add(new Studio(2013, "Lionsgate", .098, 1069.5, 26));
            _allStudios.Add(new Studio(2013, "Others", .153, 1675.1, 0));
            
            //2012
            _allStudios.Add(new Studio(2012, "Universal", .122, 1323.9, 17));
            _allStudios.Add(new Studio(2012, "20th Century Fox", .095, 1025.4, 19));
            _allStudios.Add(new Studio(2012, "Warner Bros.", .154, 1665.4, 36));
            _allStudios.Add(new Studio(2012, "Sony/Columbia", .166, 1792.2, 25));
            _allStudios.Add(new Studio(2012, "Buena Vista", .143, 1551.4, 18));
            _allStudios.Add(new Studio(2012, "Paramount", .084, 914.4, 21));
            _allStudios.Add(new Studio(2012, "Lionsgate", .114, 1239.1, 22));
            _allStudios.Add(new Studio(2012, "Others", .122, 1311.2, 0));

            //2011
            _allStudios.Add(new Studio(2011, "Universal", .102, 1040.6, 17));
            _allStudios.Add(new Studio(2011, "20th Century Fox", .096, 977.9, 19));
            _allStudios.Add(new Studio(2011, "Warner Bros.", .179, 1826.2, 38));
            _allStudios.Add(new Studio(2011, "Sony/Columbia", .125, 1273.7, 28));
            _allStudios.Add(new Studio(2011, "Buena Vista", .122, 1240.7, 17));
            _allStudios.Add(new Studio(2011, "Paramount", .192, 1957.1, 21));
            _allStudios.Add(new Studio(2011, "Lionsgate", .018, 184, 15));
            _allStudios.Add(new Studio(2011, "Others", .166, 1673.8, 0));
        }
    }
}
