using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Data;
using Telerik.Windows.Data;
using TimeBarFirstLook_WCF_RIA.Web;

namespace TimeBarFirstLook_WCF_RIA.Converters
{
    public class PieConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            IEnumerable<FlightStatisticsView> data = (value as DataItemCollection).Cast<FlightStatisticsView>();

            return (from p in data
                    select new FlightRecords() { Type = "Arrival", TimeStamp = p.TimeStamp, FlightCount = p.Arrivals }).Concat(
                    from p in data
                    select new FlightRecords() { Type = "Departures", TimeStamp = p.TimeStamp, FlightCount = p.Departures });
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class FlightRecords
    {
        public string Type { get; set; }
        public DateTime TimeStamp { get; set; }
        public int FlightCount { get; set; }
    }
}
