Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public ActionResult SiteDashboard(long siteID)
        {
            // Make sure the siteID belongs to a CameraSite
            if (CollectionRepository.Find(c => c.Site.ID == siteID && c.Type == CollectionType.SITE).FirstOrDefault() == null)
            {
                return(RedirectToAction("SiteList", "Home", null));
            }
            else
            {
                SiteDashboardViewModel model = new SiteDashboardViewModel();

                model.CollectionViewModel = GetCollectionViewModel(siteID, -1);
                model.Years = GetSiteYearSummary(siteID);
                model.Tags  = PhotoService.GetPopularTagsForSite(siteID);

                //Photo Frequency
                model.PhotoFrequency           = GetPhotoFrequencyData(siteID);
                model.PhotoFrequency.SiteName  = model.CollectionViewModel.Collection.Site.Name;
                model.PhotoFrequency.StartDate = model.CollectionViewModel.SiteDetails.First;

                Photo    lastPhoto     = PhotoRepository.Find(p => p.Site.ID == siteID).OrderBy(p => p.Captured).Last();
                DateTime lastPhotoDate = lastPhoto.Captured;

                model.DroughtMonitorData         = LoadDMData(DMDataType.COUNTY, lastPhotoDate, model.CollectionViewModel.Collection.Site.CountyFips);
                model.DroughtMonitorData.PhotoID = lastPhoto.ID;

                model.WaterData         = LoadWaterData(model.CollectionViewModel.Collection.Site.Latitude, model.CollectionViewModel.Collection.Site.Longitude, lastPhotoDate);
                model.WaterData.PhotoID = lastPhoto.ID;

                return(View(model));
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        } //End LoadDMDataValues

        private UserCollectionData LoadUserCollections(long photoID)
        {
            Phocalstream_Shared.Data.Model.Photo.User User = UserRepository.First(u => u.ProviderID == this.User.Identity.Name);
            if (User != null)
            {
                UserCollectionData model = new UserCollectionData();
                model.PhotoID = photoID;

                List <UserCollection>    userCollections = new List <UserCollection>();
                IEnumerable <Collection> collections     = CollectionRepository.Find(c => c.Owner.ID == User.ID && c.Site == null && c.Type != CollectionType.TIMELAPSE, c => c.Photos);

                foreach (var col in collections)
                {
                    UserCollection userCollection = new UserCollection();

                    userCollection.CollectionID   = col.ID;
                    userCollection.CollectionName = col.Name;

                    userCollection.Added = col.Photos.Select(p => p.ID).Contains(photoID);

                    userCollections.Add(userCollection);
                }

                model.Collections = userCollections;
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
        //
        // GET: /Home/
        public ActionResult Index(int e = 0)
        {
            HomeViewModel            model       = new HomeViewModel();
            ICollection <Collection> collections = CollectionRepository.Find(c => c.Status == CollectionStatus.COMPLETE && c.Type == CollectionType.SITE, c => c.CoverPhoto, c => c.Site).ToList <Collection>();

            model.Sites          = collections.Select(c => GetDetailsForCollection(c)).ToArray();
            model.SiteThumbnails = new List <ThumbnailModel>();
            foreach (var s in model.Sites)
            {
                model.SiteThumbnails.Add(new ThumbnailModel()
                {
                    ID           = s.SiteID,
                    Name         = s.SiteName,
                    First        = s.First,
                    Last         = s.Last,
                    PhotoCount   = s.PhotoCount,
                    CoverPhotoID = s.CoverPhotoID,
                    Link         = "/photo/sitedashboard?siteId=" + s.SiteID.ToString()
                });
            }

            model.Tags = PhotoService.GetTagNames();

            model.SiteIndex = new Random().Next(model.Sites.Count());

            if (e == 2)
            {
                ViewBag.Message = "Please enter at lease one search parameter.";
            }

            return(View(model));
        }
Esempio n. 6
0
        public ActionResult Timelapse(long collectionId)
        {
            TimelapseModel model      = new TimelapseModel();
            Collection     collection = CollectionRepository.Find(c => c.ID == collectionId, c => c.Photos, c => c.Site).FirstOrDefault();

            if (collection != null)
            {
                model.CollectionId = collection.ID;
                model.Name         = !String.IsNullOrWhiteSpace(collection.Name) ? collection.Name : "Dynamic Timelapse";

                long[] ids;
                switch (collection.Type)
                {
                case CollectionType.SITE:
                    ids = PhotoRepository.Find(p => p.Site.ID == collection.Site.ID).Select(p => p.ID).ToArray <long>();
                    break;

                case CollectionType.USER:
                    ids = collection.Photos.Select(p => p.ID).ToArray <long>();
                    break;

                case CollectionType.SEARCH:
                    ids = collection.Photos.Select(p => p.ID).ToArray <long>();
                    break;

                case CollectionType.TIMELAPSE:
                    ids = collection.Photos.Select(p => p.ID).ToArray <long>();
                    break;

                default:
                    ids = new long[0];
                    break;
                }

                if (ids.Length > 0)
                {
                    model.DmWeeks = DZPhotoRepository.FindDmDatesForPhotos(ids);
                    model.Frames  = PhotoService.CreateTimeLapseFramesFromIDs(ids);

                    long id = model.Frames.FirstOrDefault().PhotoID;

                    Photo first = PhotoRepository.Find(p => p.ID == id, p => p.Site).FirstOrDefault();
                    model.CountyFips = first.Site.CountyFips;
                    model.Latitude   = first.Site.Latitude;
                    model.Longitude  = first.Site.Longitude;

                    model.Width  = first.Width;
                    model.Height = first.Height;

                    return(View(model));
                }
            }

            return(RedirectToAction("Index", "Search", null));
        }
Esempio n. 7
0
        public IEnumerable <Object> GetSites()
        {
            List <Object> details = new List <Object>();

            ICollection <Collection> collections = CollectionRepository.Find(c => c.Status == CollectionStatus.COMPLETE && c.Type == CollectionType.SITE, c => c.CoverPhoto, c => c.Site).ToList <Collection>();

            foreach (Collection c in collections)
            {
                details.Add(new { Details = GetDetailsForCollection(c), Latitude = c.Site.Latitude, Longitude = c.Site.Longitude });
            }

            return(details);
        }
Esempio n. 8
0
        private HttpResponseMessage loadPhoto(long id, string res)
        {
            Photo photo = PhotoRepository.Single(p => p.ID == id, p => p.Site);

            string photoPath = "";

            if (photo == null)
            {
                photoPath = HttpContext.Current.Server.MapPath("~/Content/Images/image_not_found.jpg");
            }
            else
            {
                Collection collection = CollectionRepository.Find(c => c.Site.ID == photo.Site.ID, c => c.Owner).FirstOrDefault();

                if (collection.Type == CollectionType.SITE)
                {
                    photoPath = string.Format("{0}/{1}/{2}.phocalstream/{3}.jpg", PathManager.GetPhotoPath(), photo.Site.DirectoryName, photo.BlobID, res);
                }
                else if (collection.Type == CollectionType.USER)
                {
                    photoPath = string.Format("{0}/{1}/{2}/{3}.phocalstream/{4}.jpg", PathManager.GetUserCollectionPath(), collection.Owner.ID,
                                              collection.ContainerID, photo.BlobID, res);
                }
                else
                {
                    photoPath = HttpContext.Current.Server.MapPath("~/Content/Images/image_not_found.jpg");
                }
            }

            MemoryStream imageData = new MemoryStream();

            using (FileStream stream = File.OpenRead(photoPath))
            {
                int    len = 0;
                byte[] buf = new byte[1024];
                while ((len = stream.Read(buf, 0, 1024)) > 0)
                {
                    imageData.Write(buf, 0, len);
                }
            }
            imageData.Position = 0;

            HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);

            message.Content = new StreamContent(imageData);
            message.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");

            return(message);
        }
Esempio n. 9
0
        public void AddToExistingUserCollection(User user, string collectionIds, string photoIds)
        {
            long[]       ids    = photoIds.Split(',').Select(i => Convert.ToInt64(i)).ToArray();
            List <Photo> photos = PhotoRepository.Find(p => ids.Contains(p.ID)).ToList();

            long[]            cIds        = collectionIds.Split(',').Select(i => Convert.ToInt64(i)).ToArray();
            List <Collection> collections = CollectionRepository.Find(c => cIds.Contains(c.ID) && c.Type == CollectionType.USER, c => c.Photos).ToList();

            foreach (var col in collections)
            {
                col.Photos = col.Photos.Union(photos).ToList();
                col.Status = CollectionStatus.INVALID;
            }
            Unit.Commit();
        }
Esempio n. 10
0
        public List <UserSite> GetUserSites()
        {
            var user = UserRepository.Find(u => u.ProviderID == User.Identity.Name).FirstOrDefault();

            Debug.Assert(user != null);

            var collections = CollectionRepository.Find(c => c.Owner.ID == user.ID & c.Site != null & c.Photos.Count != 0, c => c.Owner, c => c.Photos, c => c.CoverPhoto);

            return(collections.Select(c => new UserSite
            {
                CollectionID = c.ID,
                CoverPhotoID = c.Photos.Last().ID,
                From = c.Photos.First().Captured,
                To = c.Photos.Last().Captured,
                Name = c.Name,
                PhotoCount = c.Photos.Count
            }).ToList <UserSite>());
        }
Esempio n. 11
0
        public Collection GetCollectionForProcessing(XmlNode siteData)
        {
            string     siteName   = siteData["Folder"].InnerText;
            CameraSite site       = SiteRepository.Find(s => s.Name == siteName).FirstOrDefault();
            Collection collection = null;

            if (site == null)
            {
                site               = new CameraSite();
                site.Name          = siteData["Folder"].InnerText;
                site.DirectoryName = siteData["Folder"].InnerText;
                site.ContainerID   = Guid.NewGuid().ToString();
                if (siteData["Location"].Attributes["latitude"].Value != String.Empty)
                {
                    site.Latitude  = Convert.ToDouble(siteData["Location"].Attributes["latitude"].Value);
                    site.Longitude = Convert.ToDouble(siteData["Location"].Attributes["longitude"].Value);
                }

                var county = siteData["County"].InnerText;
                var state  = siteData["State"].InnerText;
                site.CountyFips = DMRepository.GetFipsForCountyAndState(county, state);

                collection = new Collection()
                {
                    ContainerID = site.ContainerID,
                    Name        = site.Name,
                    Site        = site,
                    Status      = CollectionStatus.PROCESSING,
                    Type        = CollectionType.SITE
                };

                CollectionRepository.Insert(collection);
                SiteRepository.Insert(site);
            }
            else
            {
                collection        = CollectionRepository.Find(c => c.Site.ID == site.ID).FirstOrDefault();
                collection.Status = CollectionStatus.PROCESSING;
                CollectionRepository.Update(collection);
            }

            return(collection);
        }
Esempio n. 12
0
        //Do these delete methods need to be secured?
        public void DeleteAllUserCollections()
        {
            IEnumerable <Collection> collections = CollectionRepository.Find(c => c.Type == CollectionType.USER);

            var collectionPath = ValidateAndGetUserCollectionPath();

            foreach (var col in collections)
            {
                string filePath = Path.Combine(collectionPath, col.ContainerID);

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

                CollectionRepository.Delete(col);
                Unit.Commit();
            }
        }
Esempio n. 13
0
        public ActionResult Index(long collectionId = -1, string tag = "", string site = "", string year = "")
        {
            SearchModel model = new SearchModel();

            model.AvailableTags = PhotoService.GetTagNames();
            model.SiteNames     = SearchService.GetSiteNames();

            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.Site == null && c.Type == CollectionType.USER, c => c.Photos).ToList();
                model.UserCollections           = userCollectionModel;

                ViewBag.UserId = User.ID;
            }


            Collection collection = CollectionRepository.Find(c => c.ID == collectionId).FirstOrDefault();

            if (collection != null && !collection.Public && collection.Type == CollectionType.USER)
            {
                // If the collection is a user collection, and it does not belong to current user
                if (User == null || collection.Owner.ID != User.ID)
                {
                    collection = null;
                }
            }

            if (collection != null)
            {
                ViewBag.CollectionId = collection.ID;
            }

            ViewBag.Tag  = tag;
            ViewBag.Site = site;
            ViewBag.Year = year;

            return(View(model));
        }
Esempio n. 14
0
        public ActionResult UploadPhotos(long collectionID = 0)
        {
            User user = UserRepository.First(u => u.ProviderID == this.User.Identity.Name);

            if (user == null)
            {
                return(RedirectToAction("Login"));
            }

            UserPhotoUpload model = new UserPhotoUpload();

            model.UserSiteCollections = CollectionRepository.Find(c => c.Type == CollectionType.USER && c.Owner.ID == user.ID && c.Site != null, c => c.Site).ToList();

            if (model.UserSiteCollections.Count == 0)
            {
                return(RedirectToAction("CreateUserSite", new { e = 1 }));
            }

            ViewBag.CollectionID = collectionID;

            return(View(model));
        }
Esempio n. 15
0
        public ActionResult SiteList()
        {
            HomeViewModel model = new HomeViewModel();

            model.Collections    = CollectionRepository.Find(c => c.Status == CollectionStatus.COMPLETE && c.Type == CollectionType.SITE, c => c.CoverPhoto, c => c.Site).ToList <Collection>();
            model.Sites          = model.Collections.Select(c => GetDetailsForCollection(c)).ToArray();
            model.SiteThumbnails = new List <ThumbnailModel>();
            foreach (var s in model.Sites)
            {
                model.SiteThumbnails.Add(new ThumbnailModel()
                {
                    ID           = s.SiteID,
                    Name         = s.SiteName,
                    First        = s.First,
                    Last         = s.Last,
                    PhotoCount   = s.PhotoCount,
                    CoverPhotoID = s.CoverPhotoID,
                    Link         = "/photo/sitedashboard?siteId=" + s.SiteID.ToString()
                });
            }
            return(View(model));
        }
Esempio n. 16
0
        public List <string> GetFileNames(List <Photo> photos)
        {
            List <string> fileNames = new List <string>();

            foreach (Photo photo in photos)
            {
                Collection collection = CollectionRepository.Find(c => c.Site.ID == photo.Site.ID, c => c.Owner).FirstOrDefault();

                if (collection.Type == CollectionType.SITE)
                {
                    fileNames.Add(Path.Combine(PathManager.GetPhotoPath(), photo.Site.DirectoryName,
                                               string.Format("{0}.phocalstream", photo.BlobID), "Tiles.dzi"));
                }
                else if (collection.Type == CollectionType.USER)
                {
                    fileNames.Add(Path.Combine(PathManager.GetUserCollectionPath(), Convert.ToString(collection.Owner.ID), photo.Site.DirectoryName,
                                               string.Format("{0}.phocalstream", photo.BlobID), "Tiles.dzi"));
                }
            }

            return(fileNames);
        }
Esempio n. 17
0
        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));
        }
Esempio n. 18
0
        public Photo ProcessUserPhoto(Stream stream, string fileName, User user, long collectionID)
        {
            Collection collection = CollectionRepository.Find(c => c.ID == collectionID && c.Type == CollectionType.USER, c => c.Site, c => c.Photos).FirstOrDefault();

            string userFolder = Path.Combine(PathManager.GetUserCollectionPath(), Convert.ToString(user.ID));

            if (!Directory.Exists(userFolder))
            {
                Directory.CreateDirectory(userFolder);
            }

            try
            {
                // create the directory for the image and its components
                string basePath = Path.Combine(userFolder, collection.ContainerID, string.Format("{0}.phocalstream", fileName));
                if (!Directory.Exists(basePath))
                {
                    Directory.CreateDirectory(basePath);
                }

                // open a Bitmap for the image to parse the meta data from
                using (System.Drawing.Image img = System.Drawing.Image.FromStream(stream))
                {
                    string savePath = Path.Combine(basePath, fileName);
                    img.Save(savePath);

                    Photo photo = CreatePhotoWithProperties(img, fileName);
                    photo.FileName = fileName;
                    photo.Site     = collection.Site;

                    PhotoRepository.Insert(photo);

                    collection.Photos.Add(photo);
                    collection.Status = CollectionStatus.INVALID;

                    // if first photo, set as cover photo
                    if (collection.Photos.Count == 1)
                    {
                        collection.CoverPhoto = photo;
                    }

                    Unit.Commit();

                    // only generate the phocalstream image if it has not already been generated
                    if (File.Exists(Path.Combine(basePath, @"High.jpg")) == false)
                    {
                        // this is a dirty hack, figure out why the image isn't opening with the correct width and height
                        if (photo.Portrait)
                        {
                            photo.Width  = img.Height;
                            photo.Height = img.Width;
                        }

                        ResizeImageTo(savePath, 1200, 800, Path.Combine(basePath, @"High.jpg"), photo.Portrait);
                        ResizeImageTo(savePath, 800, 533, Path.Combine(basePath, @"Medium.jpg"), photo.Portrait);
                        ResizeImageTo(savePath, 400, 266, Path.Combine(basePath, @"Low.jpg"), photo.Portrait);
                    }

                    return(photo);
                }
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("Exception processing photo {0}. Message: {1}", fileName, e.Message));
            }
        }
Esempio n. 19
0
        public long NewTimelapseCollection(User user, string timelapseName, string photoIds)
        {
            // Use the hash of the photoIds as the container id so we can check if timelapse already exists
            string containerID = Convert.ToString(photoIds.GetHashCode());

            List <Photo> photos;

            long[] ids;

            // Only logged in users can own and name a collection
            if (user != null)
            {
                // See if the user already has a collection for those photos, if so return that collection id
                Collection existingUserCollection = CollectionRepository.Find(c => c.ContainerID == containerID & c.Owner.ID == user.ID).FirstOrDefault();
                if (existingUserCollection != null)
                {
                    // see if the name is the same, if not, overwrite
                    if (!existingUserCollection.Name.Equals(timelapseName))
                    {
                        existingUserCollection.Name = timelapseName;
                        Unit.Commit();
                    }

                    return(existingUserCollection.ID);
                }
                else
                {
                    if (!String.IsNullOrWhiteSpace(photoIds))
                    {
                        ids    = photoIds.Split(',').Select(i => Convert.ToInt64(i)).ToArray();
                        photos = PhotoRepository.Find(p => ids.Contains(p.ID), p => p.Site).ToList();

                        Collection c = new Collection()
                        {
                            Name        = timelapseName,
                            ContainerID = containerID.ToString(),
                            Owner       = user,
                            Type        = CollectionType.TIMELAPSE,
                            Status      = CollectionStatus.COMPLETE,
                            Photos      = photos
                        };
                        CollectionRepository.Insert(c);
                        Unit.Commit();

                        return(c.ID);
                    }
                }
            }
            else
            {
                // Since the user is not logged in, check if an un-owned copy of this collection exists
                Collection existingCollection = CollectionRepository.Find(c => c.ContainerID == containerID & c.Owner == null).FirstOrDefault();
                if (existingCollection != null)
                {
                    return(existingCollection.ID);
                }
                else
                {
                    if (!String.IsNullOrWhiteSpace(photoIds))
                    {
                        ids    = photoIds.Split(',').Select(i => Convert.ToInt64(i)).ToArray();
                        photos = PhotoRepository.Find(p => ids.Contains(p.ID), p => p.Site).ToList();

                        Collection c = new Collection()
                        {
                            Name        = timelapseName,
                            ContainerID = containerID.ToString(),
                            Owner       = null,
                            Type        = CollectionType.TIMELAPSE,
                            Status      = CollectionStatus.COMPLETE,
                            Photos      = photos
                        };
                        CollectionRepository.Insert(c);
                        Unit.Commit();

                        return(c.ID);
                    }
                }
            }

            // something went wrong, so return -1
            return(-1);
        }