using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GridAjaxDetailView.Models
{
    public class Customer
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public IEnumerable<Order> Orders
        {
            get
            {
                return FakeContext.Orders.Where(o => o.CustomerID == ID);
            }
        }
    }

    public class Order
    {
        public int ID { get; set; }
        public int CustomerID { get; set; }
        public DateTime ShipDate { get; set; }
    }

    public static class FakeContext
    {
        static IEnumerable<Order> _orders;
        static IEnumerable<Customer> _customers;

        static FakeContext()
        {
            _customers = Enumerable.Range(1, 10).Select(i => new Customer {
                ID = i,
                Name = "Customer" + i
            }).ToList();

            var rand = new Random();
            _orders = Enumerable.Range(1, 100).Select(i => new Order
            {
                ID = i,
                CustomerID = rand.Next(10),
                ShipDate = DateTime.Now.AddDays(rand.Next(100))
            }).ToList();
        }

        public static IEnumerable<Order> Orders
        {
            get
            {
                return _orders;
            }
        }

        public static IEnumerable<Customer> Customers
        {
            get
            {
                return _customers;
            }
        }
    }
}