﻿using DertInfo.WEB.Models;
using DertInfo.WEB.ViewModels.TeamVMs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DertInfo.WEB.ViewModels.ContentVMs
{
    public class Team_Listing_ContentViewModel
    {
        public Team_Listing_ContentViewModel()
        {
            this.TeamContentVMs = new List<TeamContentViewModel>();
        }

        public Team_Listing_ContentViewModel(IEnumerable<Team> teams)
        {
            this.TeamContentVMs = new List<TeamContentViewModel>();

            this.ToView(teams);
        }

        //Properties
        public List<TeamContentViewModel> TeamContentVMs { get; set; }

        private void ToView(IEnumerable<Team> teams)
        {
            foreach (Team team in teams.OrderBy(t => t.TeamName))
            {
                TeamContentViewModel teamContentVM = new TeamContentViewModel(team);

                if (teamContentVM.EventVMs.Count() > 0)
                {
                    this.TeamContentVMs.Add(teamContentVM);
                }
            }
        }
    }
}