Exemple #1
0
        public void SetUserCollectionPublic(User user, long collectionID, bool publish)
        {
            Collection collection = CollectionRepository.First(c => c.ID == collectionID && c.Owner.ID == user.ID);

            collection.Public = publish;
            Unit.Commit();
        }
        private CollectionViewModel GetCollectionViewModel(long siteID, long year)
        {
            CollectionViewModel model = new CollectionViewModel();

            model.Collection = CollectionRepository.First(c => c.Site.ID == siteID);
            model.SiteCoords = string.Format("{0}, {1}", model.Collection.Site.Latitude, model.Collection.Site.Longitude);

            List <Photo> photos = PhotoRepository.Find(p => p.Site.ID == model.Collection.Site.ID).OrderBy(p => p.Captured).ToList <Photo>();

            if (year != -1)
            {
                photos = photos.Where(p => p.Captured.Year == year).ToList <Photo>();
            }

            model.SiteDetails = new SiteDetails()
            {
                PhotoCount = photos.Count(), First = photos.Select(p => p.Captured).First(), Last = photos.Select(p => p.Captured).Last()
            };

            Phocalstream_Shared.Data.Model.Photo.User User = UserRepository.First(u => u.ProviderID == this.User.Identity.Name);
            if (User != null)
            {
                UserCollectionList userCollectionModel = new UserCollectionList();
                userCollectionModel.User        = User;
                userCollectionModel.Collections = CollectionRepository.Find(c => c.Owner.ID == User.ID && c.Type == CollectionType.USER, c => c.Photos).ToList();
                model.UserCollections           = userCollectionModel;
            }

            return(model);
        }
Exemple #3
0
        public void SetUserCollectionCoverPhoto(User user, long collectionID, long photoID)
        {
            Collection collection = CollectionRepository.First(c => c.ID == collectionID && c.Owner.ID == user.ID);
            Photo      photo      = PhotoRepository.First(p => p.ID == photoID);

            collection.CoverPhoto = photo;
            Unit.Commit();
        }
Exemple #4
0
        public void RemoveFromExistingUserCollection(User user, long collectionID, string photoIds)
        {
            long[]       ids    = photoIds.Split(',').Select(i => Convert.ToInt64(i)).ToArray();
            List <Photo> photos = PhotoRepository.Find(p => ids.Contains(p.ID)).ToList();

            Collection collection = CollectionRepository.First(c => c.ID == collectionID && c.Type == CollectionType.USER, c => c.Photos);

            collection.Photos = collection.Photos.Except(photos).ToList();
            collection.Status = CollectionStatus.INVALID;
            Unit.Commit();
        }
        public ActionResult SiteDetails(long id)
        {
            Collection collection = CollectionRepository.First(c => c.Site.ID == id, c => c.Site, c => c.CoverPhoto);

            Phocalstream_Shared.Data.Model.View.SiteDetails details = PhotoRepository.GetSiteDetails(collection.Site);

            details.LastPhotoURL = string.Format("{0}://{1}:{2}/api/photo/auto/{3}", Request.Url.Scheme,
                                                 Request.Url.Host,
                                                 Request.Url.Port,
                                                 collection.CoverPhoto == null ? details.LastPhotoID : collection.CoverPhoto.ID);

            return(PartialView("_SiteDetails", details));
        }
        public ActionResult EditUserCollection(long collectionID, int count = -1)
        {
            EditUserCollection model = new EditUserCollection();

            model.Collection   = CollectionRepository.First(c => c.ID == collectionID, c => c.Photos);
            model.CoverPhotoId = model.Collection.CoverPhoto != null ? model.Collection.CoverPhoto.ID : 0;

            if (count != -1)
            {
                if (count == 1)
                {
                    ViewBag.Message = "Successfully deleted 1 photo.";
                }
                else
                {
                    ViewBag.Message = string.Format("Successfully deleted {0} photos.", count.ToString());
                }
            }

            return(View(model));
        }
Exemple #7
0
        public bool DeleteUserCollection(long currentUserId, long collectionID)
        {
            Collection col = CollectionRepository.First(c => c.ID == collectionID && c.Owner.ID == currentUserId && c.Type != CollectionType.SITE);

            if (col != null)
            {
                string filePath = Path.Combine(ValidateAndGetUserCollectionPath(), col.ContainerID);

                if (System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.Delete(filePath, true);
                }

                CollectionRepository.Delete(col);
                Unit.Commit();

                return(true);
            }

            return(false);
        }
Exemple #8
0
        public void TogglePhotoInUserCollection(long photoID, long collectionID)
        {
            Collection col = CollectionRepository.First(c => c.ID == collectionID, c => c.Photos);

            if (col.Type == CollectionType.USER)
            {
                Photo photo = PhotoRepository.Find(photoID);

                if (col.Photos.Contains(photo))
                {
                    col.Photos.Remove(photo);
                }
                else
                {
                    col.Photos.Add(photo);
                }

                col.Status = CollectionStatus.INVALID;
                Unit.Commit();
            }
        }