public static IList<CustomerModel> All()
        {
            IList<CustomerModel> result = HttpContext.Current.Session["Customers"] as IList<CustomerModel>;

            if (result == null)
            {
                HttpContext.Current.Session["Customers"] = result = new SampleDataContext().Customers.Select(c => new CustomerModel
                {
                    CustomerID = c.CustomerID,
                    ContactName = c.ContactName,
                    CompanyName = c.CompanyName,
                }).ToList();
            }

            return result;
        }
        public static IList<WeatherModel> ByMonth(string station, int year, int month)
        {
            var sessionKey = "w_byMonth_" + station + year + month;
            var result = HttpContext.Current.Session[sessionKey] as IList<WeatherModel>;

            if (result == null)
            {
                using (var db = new SampleDataContext()) {
                    HttpContext.Current.Session[sessionKey] = result =
                        ByStation(station)
                            .Where(w => w.Date.Year == year && w.Date.Month == month)
                            .ToList();
                }
            }

            return result;
        }
        public static IList<OrderModel> All()
        {
            IList<OrderModel> result = HttpContext.Current.Session["Orders"] as IList<OrderModel>;

            if (result == null)
            {
                HttpContext.Current.Session["Customers"] = result = new SampleDataContext().Orders.Select(c => new OrderModel
                {
                    OrderID = c.OrderID,
                    ShipName = c.ShipName,
                    ShipCity = c.ShipCity,
                    ShipCountry = c.ShipCountry
                }).ToList();
            }

            return result;
        }
        public static IList<EmployeeModel> All()
        {
            IList<EmployeeModel> result = HttpContext.Current.Session["Employees"] as IList<EmployeeModel>;

            if (result == null)
            {
                HttpContext.Current.Session["Employees"] = result = new SampleDataContext().Employees.Select(e => new EmployeeModel
                    {
                        EmployeeId = e.EmployeeID,
                        FullName = e.FirstName + " " + e.LastName,
                        ReportsTo = e.ReportsTo,
                        HasEmployees = e.Employees.Count > 0
                    }).ToList();
            }

            return result;
        }
        public static IList<EmployeeCompleteModel> AllComplete()
        {
            IList<EmployeeCompleteModel> result = HttpContext.Current.Session["EmployeesComplete"] as IList<EmployeeCompleteModel>;

            if (result == null)
            {
                HttpContext.Current.Session["EmployeesComplete"] = result = new SampleDataContext().Employees.Select(m => new EmployeeCompleteModel {
                    FirstName = m.FirstName,
                    LastName = m.LastName,
                    Country = m.Country,
                    City = m.City,
                    Title = m.Title
                }).ToList();
            }

            return result;
        }
        public static IList<ProductModel> All()
        {
            var result = HttpContext.Current.Session["Products"] as IList<ProductModel>;

            if (result == null)
            {
                HttpContext.Current.Session["Products"] = result =
                    new SampleDataContext().Products.Select(p => new ProductModel
                     {
                         ProductID = p.ProductID,
                         ProductName = p.ProductName,
                         UnitPrice = (double)p.UnitPrice.GetValueOrDefault(),
                         UnitsInStock = p.UnitsInStock.GetValueOrDefault(),
                         Discontinued = p.Discontinued                         
                     }).ToList();
            }

            return result;
        }
        public static IList<WeatherModel> ByStation(string station)
        {
            var sessionKey = "w_byStation_" + station;
            var result = HttpContext.Current.Session[sessionKey] as IList<WeatherModel>;

            if (result == null)
            {
                HttpContext.Current.Session[sessionKey] = result =
                    new SampleDataContext().Weather.Select(w => new WeatherModel
                     {
                         Date = w.Date,
                         TMax = w.TMax,
                         TMin = w.TMin,
                         Rain = w.Rain,
                         Wind = w.Wind
                     }).ToList();
            }

            return result;
        }
        public IEnumerable<ProductSignalR> Read()
        {
            var products = HttpContext.Current.Cache["products"] as IEnumerable<ProductSignalR>;

            if (products == null)
            {
                using (var context = new SampleDataContext())
                {
                    var createdAt = DateTime.Now;

                    products = context.Products
                                      .OrderBy(p => p.ProductName)
                                      .ToList() // Execute the query because Linq to SQL doesn't get Guid.NewGuid()
                                      .Select(p => new ProductSignalR
                                      {
                                           ID = Guid.NewGuid(),
                                           ProductName = p.ProductName,
                                           UnitPrice = (double)p.UnitPrice.GetValueOrDefault(),
                                           UnitsInStock = p.UnitsInStock.GetValueOrDefault(),
                                           CreatedAt = createdAt = createdAt.AddMilliseconds(1)
                                      })
                                      .ToList();
                }

                HttpContext.Current.Cache.Add("products", 
                    products, 
                    null, 
                    Cache.NoAbsoluteExpiration, 
                    TimeSpan.FromMinutes(30), 
                    System.Web.Caching.CacheItemPriority.Normal, 
                    null
                );
            }

            return products;
        }