private List<ThumbnailModel> GetSiteYearSummary(long siteID)
        {
            List<ThumbnailModel> Years = new List<ThumbnailModel>();

            string siteName = CollectionRepository.Find(c => c.Site.ID == siteID).FirstOrDefault().Site.Name;

            List<int> yearStrings = PhotoRepository.Find(p => p.Site.ID == siteID).Select(p => p.Captured.Year).Distinct().ToList<int>();

            foreach (int y in yearStrings)
            {
                ThumbnailModel model = new ThumbnailModel();

                model.Name = Convert.ToString(y);

                Photo[] photos = PhotoRepository.Find(p => p.Site.ID == siteID && p.Captured.Year == y)
                                                            .ToArray();
                model.PhotoCount = photos.Count();
                model.First = photos[0].Captured;
                model.Last = photos[photos.Count() - 1].Captured;

                photos = photos.Where(p => p.Captured.Hour > 12 && p.Captured.Hour < 16).ToArray();

                Random rand = new Random();
                model.CoverPhotoID = photos[rand.Next(photos.Length)].ID;

                model.Link = "/Search/Index?site=" + siteName + "&year=" + model.Name;

                Years.Add(model);
            }

            return Years;
        }
        public ActionResult UserCollections(int e = 0)
        {
            UserCollectionList model = new UserCollectionList();

            Phocalstream_Shared.Data.Model.Photo.User User = UserRepository.First(u => u.ProviderID == this.User.Identity.Name);
            model.User = User;

            model.SiteThumbnails = new List<ThumbnailModel>();
            model.TimelapseThumbnails = new List<ThumbnailModel>();
            model.CollectionThumbnails = new List<ThumbnailModel>();

            model.Collections = CollectionRepository.Find(c => c.Owner.ID == User.ID, c => c.Photos).ToList<Collection>();
            foreach (var col in model.Collections)
            {
                if (col.CoverPhoto == null)
                {
                    col.CoverPhoto = col.Photos.LastOrDefault();
                }

                var thumb = new ThumbnailModel()
                {
                    ID = col.ID,
                    Name = col.Name,
                    PhotoCount = col.Photos.Count,
                    Link = "/search/index?collectionId=" + col.ID.ToString(),

                    CanEdit = true,
                    EditLink = "/Account/EditUserCollection?collectionID=" + col.ID.ToString(),
                    CanDelete = true,
                    DeleteLink = "/Account/DeleteUserCollection?collectionID=" + col.ID.ToString()
                };

                if (thumb.PhotoCount > 0)
                {
                    thumb.First = col.Photos.First().Captured;
                    thumb.Last = col.Photos.Last().Captured;
                    thumb.CoverPhotoID = col.CoverPhoto.ID;
                }

                switch (col.Type)
                {
                    case CollectionType.TIMELAPSE:
                        model.TimelapseThumbnails.Add(thumb);
                        break;
                    case CollectionType.USER:
                        if (col.Site == null)
                        {
                            model.CollectionThumbnails.Add(thumb);
                        }
                        else
                        {
                            model.SiteThumbnails.Add(thumb);
                        }
                        break;
                }
            }

            if (e == 1)
            {
                ViewBag.Message = "That collection doesn't contain any photos.";
            }
            else if (e == 2)
            {
                ViewBag.Message = "Successfully deleted collection.";
            }
            else if (e == 3)
            {
                ViewBag.Message = "Error deleting collection.";
            }

            return View(model);
        }