public void CanSavePersonToSampleChurch()
        {
            var noPeopleInSampleChurch = _context.PersonChurches.Count(pc => pc.ChurchId == 6);
            var permissionRepository = new PermissionRepository();
            var churchRepository = new ChurchRepository();
            var personRepository = new PersonRepository(permissionRepository, churchRepository);
            var emailSender = new EmailSender(new MessageRepository(), new MessageRecepientRepository(), new MessageAttachmentRepository(), personRepository);
            var churchEmailTemplateRepository = new ChurchEmailTemplatesRepository();
            var emailService = new EmailService(new UsernamePasswordRepository(permissionRepository), personRepository, new GroupRepository(), emailSender, new EmailContentService(new EmailContentRepository()), churchEmailTemplateRepository, permissionRepository);
            var uploadPhotoRepository = new PhotoRepository();
            var personService = new PersonService(
                personRepository,
                new PersonGroupRepository(personRepository),
                permissionRepository,
                new PersonRoleRepository(),
                new PersonOptionalFieldRepository(),
                new RelationshipRepository(personRepository),
                new ChurchMatcherRepository(),
                new GroupRepository(),
                new FamilyRepository(uploadPhotoRepository),
                emailService,
                new AddressRepository(),
                uploadPhotoRepository
                );
            personService.SavePersonToSampleChurch("test1", "test1", "liveId1", "", "", 47);

            var updatedNoPeopleInSampleChurch = _context.PersonChurches.Count(pc => pc.ChurchId == 6);
            Assert.That(updatedNoPeopleInSampleChurch, Is.EqualTo(noPeopleInSampleChurch + 1));
        }
Esempio n. 2
0
        public List<Photo> GetAllPhotos()
        {
            var repository = new PhotoRepository();
            var photoList = new List<Photo>();

            repository.GetAllPhotos().ForEach(x => photoList.Add(new Photo() { ID = x.ID, Description = x.Description }));

            return photoList;
        }
Esempio n. 3
0
 public SqlDAL()
 {
     DBContext = new AlbumsDBModel();
     _albumRepository = new AlbumRepository(DBContext);
     _roleRepository = new RoleRepository(DBContext);
     _userRepository = new UserRepository(DBContext);
     _commentRepository = new CommentRepository(DBContext);
     _likeRepository = new LikeRepository(DBContext);
     _albumsPhotoRepository = new AlbumsPhotoRepository(DBContext);
     _photoRepository = new PhotoRepository(DBContext);
 }
        public AjaxControlToolkit.Slide[] GetSlides(String contextKey)
        {
            if (String.IsNullOrEmpty(contextKey))
                return null;

            Guid userId = new Guid(contextKey.Split(';')[0]);
            Guid showId = new Guid(contextKey.Split(';')[1]);

            try
            {
                IPhotoRepository photoRepo = new PhotoRepository(new PhishDatabase(new ConnectionString(new AppConfigManager(), connKey)));

                PhotoService photoService = new PhotoService(photoRepo);

                var photos = photoService.GetPhotosByUserAndShow(userId, showId).Where(x => x.Thumbnail == false).ToList();

                if (photos == null || photos.Count <= 0)
                    return GetNoImagesFoundDirectory("There are no images for this show", string.Empty);

                // create generic empty list of slides
                List<AjaxControlToolkit.Slide> list = new List<AjaxControlToolkit.Slide>();
                String justFileName;
                String displayedFileTitleOnSlider;
                String displayedFileDescriptionOnSlider;

                foreach (var photo in photos)
                {
                    // get complete filename
                    justFileName = photo.FileName;

                    // get title
                    displayedFileTitleOnSlider = photo.NickName;

                    // set description
                    displayedFileDescriptionOnSlider = photo.Notes;

                    // add file to list of slides
                    list.Add(new AjaxControlToolkit.Slide(showImagesFolder + justFileName, displayedFileTitleOnSlider, displayedFileDescriptionOnSlider));
                }

                return (list.ToArray());
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Esempio n. 5
0
        public ActionResult Create(HttpPostedFileBase file_upload, FormCollection collection)
        {
            ImagePaths photoPaths = null;
            ImageDimensions imgDims = null;
            ImagePaths thumbNailPaths = null;

            try
            {
                photoPaths = SaveUploadedFile(file_upload);
                imgDims = ImageHandler.GetImageDimensions(photoPaths.FilePath);

                //Save file
                var photo = new Photo();
                photo.PhotoUrl = photoPaths.SqlAddress;
                if (imgDims != null)
                {
                    photo.Width = imgDims.Width;
                    photo.Height = imgDims.Height;
                }
                var photoRepo = new PhotoRepository();
                photoRepo.Save(photo);

                var team = new Team {TeamName = collection.Get("TeamName")};

                //Save Location
                var locationRepo = new LocationRepository();
                var location = new Location();
                location.City = collection.Get("City");
                location.StateId = Convert.ToInt32(collection.Get("StateId"));
                locationRepo.Add(location);

                team.LocationId = location.LocationId;
                team.PhotoId = photo.PhotoId;

                this.repo.Add(team);

                return RedirectToAction("Index");
            }
            catch
            {
                ViewBag.States = this.GetStates();
                return View();
            }
        }
        public ActionResult Describe(int id)
        {
            UserModel authUser = (User.Identity.IsAuthenticated ?
                new UserRepository().GetByUsername( User.Identity.Name ) : null);

            // check if photo with given id exists
            PhotoRepository photos = new PhotoRepository();
            PhotoModel photo = photos.GetById( id, withAlbum: true );
            if ( photo == null )
                throw new Exception( "photo not found" );

            // check if the caller can access the album containing the photo
            AlbumRepository albums = new AlbumRepository();
            AlbumModel album = albums.GetById( photo.Album.Id, withUser: true, withTrustedUsers: true );
            if ( !albums.IsUserAuthorizedToViewAlbum( album, authUser, false ) )
                throw new Exception( "user not authorized to view this photo/album" );

            // send back the photo information
            return Json( new
            {
                ok = true,
                data = new
                {
                    id = photo.Id,
                    album = string.Format( "{0}/api/albums/{1}", Helpers.BaseURL(), album.Id ),
                    date = new
                    {
                        day = photo.Date.Day,
                        month = photo.Date.Month,
                        year = photo.Date.Year
                    },
                    description = photo.Description,
                    image = Helpers.BaseURL() + photo.Path,
                    thumbnail = Helpers.BaseURL() + photo.Path.Substring(0, photo.Path.LastIndexOf(".jpg")) + "_mini.jpg",
                    latitude = photo.LocationLatitude,
                    longitude = photo.LocationLongitude
                }
            }, JsonRequestBehavior.AllowGet );
        }
Esempio n. 7
0
 public IEnumerable <PhotoComment> GetComments(string photoId)
 {
     return(PhotoRepository.GetComments(photoId));
 }
 public HomeController()
 {
     repository = new PhotoRepository();
 }
Esempio n. 9
0
 public void AddPhoto(Photo photo)
 {
     PhotoRepository.AddPhoto(photo);
 }
Esempio n. 10
0
 public PhotoGet()
 {
     photoRepository = new PhotoRepository();
 }
Esempio n. 11
0
        public async Task <IEnumerable <PhotoResource> > GetPhotos(int vehicleId)
        {
            var photos = await PhotoRepository.GetPhotos(vehicleId);

            return(Mapper.Map <IEnumerable <Photo>, IEnumerable <PhotoResource> >(photos));
        }
Esempio n. 12
0
 public UserPhotosController(ILogger <UserPhotosController> logger, AlbumRepository albumRepository, PhotoRepository photoRepository)
 {
     _logger          = logger;
     _albumRepository = albumRepository;
     _photoRepository = photoRepository;
 }
Esempio n. 13
0
        public ActionResult Delete(Guid id)
        {
            PhotoRepository.Delete(id);

            return(null);
        }
Esempio n. 14
0
 public SavePhotoCommand(PhotoRepository photoRepository, PhotoDetailViewModel viewModel, IMessenger messenger)
 {
     this.photoRepository = photoRepository;
     this.viewModel       = viewModel;
     this.messenger       = messenger;
 }
 public ContentManagementController()
 {
     userRepo  = new UserRepository();
     albumRepo = new AlbumRepository();
     photoRepo = new PhotoRepository();
 }
Esempio n. 16
0
        private void GenerateSampleData()
        {
            for (int i = 0; i < 200; i++)
            {
                //Create Users
                string    rndUser = RandomString(5);
                AzureUser au      = new AzureUser
                {
                    SessionTimeout = 60,
                    IsLockedOut    = false,
                    IsOnline       = false,
                    //Timestamp = DateTime.Now,
                    LastActivityDate        = DateTime.Now,
                    LastLockoutDate         = new DateTime(1900, 1, 1),
                    LastPasswordChangedDate = new DateTime(1900, 1, 1),
                    LastLoginDate           = new DateTime(1900, 1, 1),
                    RealName     = rndUser,
                    Email        = rndUser + "@testuserdomain.com",
                    CreationDate = DateTime.Now,
                    IsApproved   = true,
                    Password     = "******",
                    Username     = rndUser + "@testuserdomain.com",
                    PartitionKey = rndUser.Substring(0, 1),
                    RowKey       = Guid.NewGuid().ToString()
                };
                new AzureUserRepository().Save(au);

                string    UID = Guid.NewGuid().ToString();
                AzureRole arm = new AzureRole
                {
                    RowKey       = UID,
                    RoleName     = "RegisteredUser",
                    PartitionKey = UID.Substring(0, 1),
                    UserRowKey   = au.RowKey,
                    Timestamp    = DateTime.Now
                };

                new AzureRoleRepository().Save(arm);

                //Create Companies
                string rndCompanyName = RandomString(5);
                var    company        = new CompanyModel(au.RowKey, rndCompanyName, "sales@" + rndCompanyName + ".com", "accounts@" + rndCompanyName + ".com", i.ToString());
                company.Country = "South Africa";
                new CompanyRepository().Save(company);

                //Create 10 Products
                for (int x = 0; x < 10; x++)
                {
                    ProductModel product;
                    byte[]       photo       = null;
                    Thread       printThread = new Thread(() =>
                    {
                        photo = CreateImage(RandomString(2));
                    });

                    printThread.SetApartmentState(ApartmentState.STA);
                    printThread.Start();
                    printThread.Join();

                    string CatID    = GetRandomCategory(categoryList);
                    string photoUrl = new PhotoRepository().SavePhoto(photo, Guid.NewGuid().ToString() + "_Test.png");
                    product                      = new ProductModel(RandomString(6), NextLoremIpsum(10), photoUrl, company.RowKey);
                    product.CategoryID           = CatID;
                    product.Description          = product.Description + " " + CatID;
                    product.FobPrice             = RandomInt().ToString();
                    product.MinimumOrderQuantity = RandomInt();
                    product.ModelNumber          = RandomInt().ToString();
                    product.PackagingAndDelivery = NextLoremIpsum(3);
                    product.PaymentTerms         = NextLoremIpsum(4);
                    product.PlaceOfOrigin        = NextLoremIpsum(2);
                    product.Port                 = NextLoremIpsum(1);
                    product.Quality              = NextLoremIpsum(2);
                    product.Specifications       = NextLoremIpsum(2);
                    product.SupplyAbility        = NextLoremIpsum(2);
                    product.Colour               = NextLoremIpsum(1);
                    product.BrandName            = NextLoremIpsum(1);

                    new ProductRepository().Save(product);
                }
            }
        }
Esempio n. 17
0
 public AdminController()
 {
     PhotoRepository = new PhotoRepository();
 }
Esempio n. 18
0
 public void DeletePhoto(Photo photo)
 {
     PhotoRepository.DeletePhoto(photo);
 }
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);
        }
Esempio n. 20
0
        public JsonResult Edit(ProductViewModel product)
        {
            try
            {
                var userRowKey = (Membership.GetUser().ProviderUserKey as string);

                //ensure that user is only able to save products under there own company if not a webmaster
                if (!User.IsInRole("Webmaster"))
                {
                    if (product.ProductData.CompanyID != userRowKey)//CompanyRowKey <==> UserRowkey
                    {
                        return(Json(new { status = "error", message = "Product Save Failed - Security Violation Occurred. Your IP Address has been logged" }));
                    }
                }

                if ((product.photo != null) || (product.ProductData.PhotoUrl != null))//save only if photo allready exists or has been supplied
                {
                    if (product.photo != null)
                    {
                        BinaryReader b          = new BinaryReader(product.photo.InputStream);
                        byte[]       binData_IN = b.ReadBytes(product.photo.ContentLength);

                        MemoryStream mstream_input = new MemoryStream(binData_IN);

                        MemoryStream mstream_output_120 = new MemoryStream();
                        MemoryStream mstream_output_160 = new MemoryStream();
                        MemoryStream mstream_output_240 = new MemoryStream();

                        var settings120 = new ResizeSettings("maxwidth=120&maxheight=120&format=png");
                        ImageBuilder.Current.Build(mstream_input, mstream_output_120, settings120, false);
                        byte[] binData_OUT_120 = mstream_output_120.ToArray();

                        var settings160 = new ResizeSettings("maxwidth=160&maxheight=160&format=png");
                        mstream_input.Seek(0, SeekOrigin.Begin);
                        ImageBuilder.Current.Build(mstream_input, mstream_output_160, settings160, false);
                        byte[] binData_OUT_160 = mstream_output_160.ToArray();

                        var settings240 = new ResizeSettings("maxwidth=240&maxheight=240&format=png");
                        mstream_input.Seek(0, SeekOrigin.Begin);
                        ImageBuilder.Current.Build(mstream_input, mstream_output_240, settings240);
                        byte[] binData_OUT_240 = mstream_output_240.ToArray();

                        var             fileName  = Guid.NewGuid().ToString();
                        PhotoRepository photoRepo = new PhotoRepository();

                        product.ProductData.PhotoUrl = photoRepo.SavePhoto(binData_OUT_120, fileName + "120.png");
                        photoRepo.SavePhoto(binData_OUT_160, fileName + "160.png");
                        photoRepo.SavePhoto(binData_OUT_240, fileName + "240.png");
                    }

                    if (product.ProductData.CategoryID == null)
                    {
                        product.ProductData.CategoryID = Settings.Default.DefaultCategoryRowkey;
                    }

                    string featuredProductMessage = string.Empty;
                    if (product.IsFeaturedProduct)
                    {
                        var companySubscription = new CompanySubscriptionRepository().GetAll().Where(c => c.CompanyRowKey == userRowKey).SingleOrDefault();

                        if (companySubscription != null)
                        {
                            var subscription = new SubscriptionProductRepository().GetAll().Where(s => s.ID == companySubscription.ProductID).SingleOrDefault();

                            if (subscription != null)
                            {
                                //get featured product count for this company
                                var count = new ProductRepository().GetByCompanyRowKey(userRowKey).Where(p => p.FeaturedProductWeight >= 1).Count();

                                if (count >= subscription.MaxFeatured)
                                {
                                    product.ProductData.FeaturedProductWeight = 0;//max featured products limit exceeded
                                    featuredProductMessage = "Featured Products Limit Has Been Reached - Please Upgrade To Add More. Maximum allowed for your subscription is " + subscription.MaxFeatured;
                                }
                                else
                                {
                                    product.ProductData.FeaturedProductWeight = subscription.Level;
                                }
                            }
                        }
                    }
                    else
                    {
                        product.ProductData.FeaturedProductWeight = 0;
                    }

                    //swap out correct placeholder image
                    product.ProductData.PhotoUrl.ToLower().Trim().Replace(Settings.Default.NoImage240Url.ToLower().Trim(), Settings.Default.NoImage120Url.ToLower().Trim());


                    new ProductRepository().Save(product.ProductData);
                    //TODO: Delete old photo on save

                    return(Json(new { status = "success", message = "Product Saved Successfully", photourl = product.ProductData.PhotoUrl }, "text/html"));
                }
                else
                {
                    return(Json(new { status = "error", message = "Product Save Failed, Please Include A Photo." }, "text/html"));
                }
            }
            catch (ImageCorruptedException)
            {
                return(Json(new { status = "error", message = "Product Save Failed, error reading image file. Please try another image." }, "text/html"));
            }
            catch
            {
                return(Json(new { status = "error", message = "Product Save Failed, Please try again later." }, "text/html"));
            }
        }
Esempio n. 21
0
 public PhotoController()
 {
     PhotoRepository   = new PhotoRepository();
     CommentRepository = new CommentRepository();
 }
Esempio n. 22
0
        public AjaxControlToolkit.Slide[] GetShowPictures(String contextKey)
        {
            if (String.IsNullOrEmpty(contextKey))
                return null;

            var showId = new Guid(contextKey);

            try
            {

                IPhotoRepository photoRepo = new PhotoRepository(new PhishDatabase(new ConnectionString(new AppConfigManager(), connKey)));

                PhotoService photoService = new PhotoService(photoRepo);

                var photos = photoService.GetPhotosByShow(showId).Where(x => x.Thumbnail == false).ToList();

                if (photos == null || photos.Count <= 0)
                {
                    var linkBuilder = new LinkBuilder();
                    var myPictureLink = linkBuilder.MyPicturesLink(showId);

                    var link = string.Format("<a href=\"{0}\">Upload your pictures here!</a>", myPictureLink);
                    
                    var name = string.Format("There are no pictures uploaded for this show. {0} You could be the first!", link);

                    return GetNoImagesFoundDirectory(name, string.Empty);
                }

                // create generic empty list of slides
                List<AjaxControlToolkit.Slide> list = new List<AjaxControlToolkit.Slide>();
                String justFileName;
                String displayedFileTitleOnSlider;
                String displayedFileDescriptionOnSlider;

                foreach (var photo in photos)
                {
                    // get complete filename
                    justFileName = photo.FileName;

                    // get title
                    displayedFileTitleOnSlider = photo.NickName;

                    // set description
                    displayedFileDescriptionOnSlider = photo.Notes;

                    // add file to list of slides
                    list.Add(new AjaxControlToolkit.Slide(showImagesFolder + justFileName, displayedFileTitleOnSlider, displayedFileDescriptionOnSlider));
                }

                return (list.ToArray());
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Esempio n. 23
0
        // GET: Photo/Details/5
        public ActionResult List(Guid id) // Album Id
        {
            var photos = PhotoRepository.Get(id);

            return(PartialView("List", photos.ToModel()));
        }
Esempio n. 24
0
 public ChangeFavorite(PhotoRepository photoRepository)
 {
     this.photoRepository = photoRepository;
 }
Esempio n. 25
0
        public bool CreateDefaults()
        {
            bool aboutIsEmpty = AboutRepository.IsEmpty().GetAwaiter().GetResult();

            //aboutIsEmpty = false;
            if (aboutIsEmpty == false)
            {
                return(false);
            }
            if (aboutIsEmpty)
            {
                try
                {
                    var newAbout = new About
                    {
                        created_at = DateTime.Now,
                        updated_at = DateTime.Now,
                        photo      = $@"http://res.cloudinary.com/djqq6o8su/image/upload/mkvg51472rnjves4etg0",
                        title      = "Mr Photographer",
                        desc       = "Photographer based in Somewhere"
                    };
                    AboutRepository.Insert(newAbout);
                    SaveAsync().GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0} Exception caught.", e);
                }
            }
            bool galleryIsEmpty = GalleryRepository.IsEmpty().GetAwaiter().GetResult();

            //galleryIsEmpty = false;
            if (galleryIsEmpty)
            {
                try
                {
                    string[] names = new string[] { "People", "Landscape" };
                    foreach (var name in names)
                    {
                        var newItem = new Gallery
                        {
                            created_at = DateTime.Now,
                            updated_at = DateTime.Now,
                            name       = name
                        };
                        GalleryRepository.Insert(newItem);
                    }
                    SaveAsync().GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0} Exception caught.", e);
                }
            }
            bool linkIsEmpty = LinkRepository.IsEmpty().GetAwaiter().GetResult();

            //linkIsEmpty = false;
            if (linkIsEmpty)
            {
                try
                {
                    string[] names = new string[] { "yourfacebookname", "yourinsntagramname", "yourtwittername", "youryourtubename" };
                    foreach (var name in names)
                    {
                        var newItem = new Link
                        {
                            created_at = DateTime.Now,
                            updated_at = DateTime.Now,
                            name       = name
                        };
                        LinkRepository.Insert(newItem);
                    }
                    SaveAsync().GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0} Exception caught.", e);
                }
            }
            bool logoIsEmpty = LogoRepository.IsEmpty().GetAwaiter().GetResult();

            //logoIsEmpty = false;
            if (logoIsEmpty)
            {
                try
                {
                    string[] photos = new string[] { "http://res.cloudinary.com/djqq6o8su/image/upload/iwrwnlkuxlbypgdn05kp" };
                    foreach (var photo in photos)
                    {
                        var newItem = new Logo
                        {
                            created_at = DateTime.Now,
                            updated_at = DateTime.Now,
                            photo      = photo
                        };
                        LogoRepository.Insert(newItem);
                    }
                    SaveAsync().GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0} Exception caught.", e);
                }
            }
            bool slideIsEmpty = SlideRepository.IsEmpty().GetAwaiter().GetResult();

            //slideIsEmpty = false;
            if (slideIsEmpty)
            {
                try
                {
                    string[] names = new string[]
                    {
                        "http://res.cloudinary.com/djqq6o8su/image/upload/rrcbpzjxm5mesjptu9lc",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/iib9veyowj3wpyirbmlo",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/qgo6zbmwwd0kyanaoynz"
                    };
                    foreach (var name in names)
                    {
                        var newItem = new Slide
                        {
                            created_at = DateTime.Now,
                            updated_at = DateTime.Now,
                            name       = name
                        };
                        SlideRepository.Insert(newItem);
                    }
                    SaveAsync().GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0} Exception caught.", e);
                }
            }
            bool photoIsEmpty = PhotoRepository.IsEmpty().GetAwaiter().GetResult();

            //photoIsEmpty = false;
            if (photoIsEmpty)
            {
                try
                {
                    string[] names = new string[]
                    {
                        "http://res.cloudinary.com/djqq6o8su/image/upload/tub2v7olse0lwbq9vzrv",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/hvxogea37wkzqv5o6kkv",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/dp62d2vwochkoy2y82ee",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/lifml3ceohhebylxgue6",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/ki6pdlhihsvaakimfnml",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/itwquw92jfpht6yi1ilk",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/jplpld8tp4bxvskdpdzr"
                    };
                    string[] names2 = new string[]
                    {
                        "http://res.cloudinary.com/djqq6o8su/image/upload/vp8ahga7g1h8f6zx2d0x",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/ozljewvxh83ahvob1aml",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/tgrcyaoqx8jwi7mksakd",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/nnsii3wvw6gn40qcldwf",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/e23tgxmvw8jkeje3apjk",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/tb0rpo4gvhxv0cyyb31z",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/k90gojfb903m7hoknvs5",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/yqmqqvltyfgt6wbza9zg",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/vrlwiz6u8gcrygbruzw3",
                        "http://res.cloudinary.com/djqq6o8su/image/upload/xapqjqz9vs5kwhqh0cr5"
                    };
                    var galleryPeople    = GalleryRepository.GetAsync(item => item.name == "People").GetAwaiter().GetResult().FirstOrDefault();
                    var galleryLandscape = GalleryRepository.GetAsync(item => item.name == "Landscape").GetAwaiter().GetResult().FirstOrDefault();
                    foreach (var name in names)
                    {
                        var newItem = new Photo
                        {
                            created_at = DateTime.Now,
                            updated_at = DateTime.Now,
                            name       = name,
                            Gallery    = galleryPeople
                        };
                        PhotoRepository.Insert(newItem);
                    }
                    foreach (var name in names2)
                    {
                        var newItem = new Photo
                        {
                            created_at = DateTime.Now,
                            updated_at = DateTime.Now,
                            name       = name,
                            Gallery    = galleryLandscape
                        };
                        PhotoRepository.Insert(newItem);
                    }
                    SaveAsync().GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0} Exception caught.", e);
                }
            }

            bool userIsEmpty = UserManager.Users.Count() == 0;

            if (userIsEmpty)
            {
                //var user = new ApplicationUser
                //{
                //    ApiToken = "some",
                //    UserName = "******",
                //    Email = "*****@*****.**",
                //    EmailConfirmed = true,
                //    DateAdd = DateTime.Now,
                //    DateUpd = DateTime.Now
                //};
                //await UserManager.CreateAsync(user, "admin");
                ApplicationDbInitializer.SeedRoles(RoleManager);
                ApplicationDbInitializer.SeedUsers(UserManager, appSettings);
                //await SaveAsync();
                //new SignInManager<User>().SignInAsync
                //UserManager.Users.ToList().ForEach( async(user)=> {
                //    await _userManager.DeleteAsync(user);
                //});
            }

            if (aboutIsEmpty || galleryIsEmpty || linkIsEmpty || logoIsEmpty || photoIsEmpty || slideIsEmpty || userIsEmpty)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 26
0
 public HomeController()
 {
     PhotoRepository = new PhotoRepository();
 }
Esempio n. 27
0
 public NotesService(string connectionString)
 {
     _noteRepository  = new NoteRepository(connectionString);
     _photoRepository = new PhotoRepository(connectionString);
 }
        public override void ProcessRequest(HttpContextBase context)
        {
            HttpRequestBase request = context.Request;
            var showIdStr = request.QueryString["s"];
            var showDateStr = request.QueryString["d"];
            HttpResponseBase response = context.Response;

            var final = string.Empty;

            if (EmptyNullUndefined(showIdStr) && EmptyNullUndefined(showDateStr))
            {
                final = GetNoImagesFound();

                response.ContentType = "application/json";
                response.ContentEncoding = Encoding.UTF8;
                response.Write(final);
                response.End();
            }

            var showService = new ShowService(Ioc.GetInstance<IShowRepository>());
            if (string.IsNullOrEmpty(showIdStr))
            {
                DateTime date;
                var success = DateTime.TryParse(showDateStr, out date);

                if (!success)
                    return;

                var s = showService.GetShow(date);

                if (s == null)
                    return;

                showIdStr = s.ShowId.ToString();
            }

            var showId = new Guid(showIdStr);

            IPhotoRepository photoRepo = new PhotoRepository(new PhishDatabase(new ConnectionString(new AppConfigManager(), connKey)));

            PhotoService photoService = new PhotoService(photoRepo);

            var photos = photoService.GetPhotosByShow(showId).Where(x => x.Thumbnail == false).ToList();

            if (photos == null || photos.Count <= 0)
            {
                final = GetNoImagesFound();
            }

            if (string.IsNullOrEmpty(final))
            {
                var json = new ImageJSONifier("records");

                foreach (var photo in photos)
                {
                    var path = (PhotoType)photo.Type != PhotoType.TicketStub ? ShowImagesFolder : TicketStubImagesFolder;

                    json.Add(new ImageItem
                    {
                        Image = path + photo.FileName,
                        Description = photo.Notes,
                        Title = photo.NickName,
                        //Thumb =  //This is a consideration.  If we want to go through the trouble of using the thumb or not
                    });
                }

                final = json.GetFinalizedJSON();
            }

            response.ContentType = "application/json";
            response.ContentEncoding = Encoding.UTF8;
            response.Write(final);
        }
Esempio n. 29
0
 public ActionResult DeletePhotos(int albumId, int[] selectedObjects)
 {
     //TODO access control
     PhotoRepository photos = new PhotoRepository();
     if (selectedObjects != null)
     {
         foreach (int id in selectedObjects)
         {
             PhotoModel photo = photos.GetById(id);
             if (photo.Album.Id == albumId)
                 photos.Delete(photo);
         }
     }
     return RedirectToAction("ManageAlbum", new { id = albumId });
 }
 public CreatePhotoList(PhotoRepository in_photoRepository, PhotoFileService in_photoFileService)
 {
     this.photoRepository  = in_photoRepository;
     this.photoFileService = in_photoFileService;
 }
Esempio n. 31
0
        public ActionResult AddPhoto(NewPhotoModel photo)
        {
            UserModel user = new UserRepository().GetByUsernameWithAlbums(HttpContext.User.Identity.Name, withFollowers: true);
            ViewBag.Albums = user.Albums;

            if (photo.Source == "remote")
                photo.FileInput = null;
            else
                photo.PhotoURL = null;
            ITransaction transaction = null;
            ISession session = null;
            try
            {
                using (Image img = FileHelper.PrepareImageFromRemoteOrLocal(photo))
                {
                    if (img == null)
                        throw new FileUploadException("Can't upload your photo. Please try again later.");

                    if (ModelState.IsValid)
                    {
                        AlbumModel selectedAlbum = null;
                        foreach (AlbumModel album in user.Albums)
                        {
                            if (album.Id == photo.AlbumId)
                            {
                                selectedAlbum = album;
                                break;
                            }
                        }

                        session = SessionProvider.SessionFactory.OpenSession();
                        transaction = session.BeginTransaction();

                        string photoName = "photo_" + DateTime.Now.ToString("yyyyMMddHHmmssff");
                        string path = FileHelper.getPhotoPathWithoutExtension(selectedAlbum, photoName) + ".jpg";
                        if (string.IsNullOrEmpty(path))
                            throw new Exception("Can't save image");

                        path = FileHelper.SavePhoto(img, selectedAlbum, photoName);
                        if (string.IsNullOrEmpty(path))
                            throw new Exception("Returned path is empty");

                        PhotoRepository repo = new PhotoRepository();
                        PhotoModel newPhoto = new PhotoModel()
                        {
                            Path = path,
                            Date = DateTime.Parse(photo.Date),
                            Description = photo.Description,
                            Album = selectedAlbum
                        };

                        double? locLatitude = img.GPSLatitude();
                        double? locLongitude = img.GPSLongitude();
                        if (locLatitude.HasValue && locLongitude.HasValue)
                        {
                            newPhoto.LocationLatitude = locLatitude.Value;
                            newPhoto.LocationLongitude = locLongitude.Value;
                        }

                        repo.Create(newPhoto);
                        System.Diagnostics.Debug.WriteLine("Created db entry " + newPhoto.Id);

                        transaction.Commit();
                        Helpers.NotifyAlbumObservers(newPhoto.Album);
                        return RedirectToAction("Show", new { id = photo.AlbumId });

                    }
                }
            }
            catch (FileUploadException ex)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                    transaction.Dispose();
                }
                if (session != null)
                    session.Dispose();
                ModelState.AddModelError("FileInput", ex.Message);
            }
            catch (Exception)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                    transaction.Dispose();
                }
                if (session != null)
                    session.Dispose();
                ModelState.AddModelError("FileInput", "Can't upload your photo. Please try again later.");
            }
            return View(photo);
        }
Esempio n. 32
0
        public override void ProcessRequest(HttpContextBase context)
        {
            HttpRequestBase  request     = context.Request;
            var              showIdStr   = request.QueryString["s"];
            var              showDateStr = request.QueryString["d"];
            HttpResponseBase response    = context.Response;

            var final = string.Empty;

            if (EmptyNullUndefined(showIdStr) && EmptyNullUndefined(showDateStr))
            {
                final = GetNoImagesFound();

                response.ContentType     = "application/json";
                response.ContentEncoding = Encoding.UTF8;
                response.Write(final);
                response.End();
            }

            var showService = new ShowService(Ioc.GetInstance <IShowRepository>());

            if (string.IsNullOrEmpty(showIdStr))
            {
                DateTime date;
                var      success = DateTime.TryParse(showDateStr, out date);

                if (!success)
                {
                    return;
                }

                var s = showService.GetShow(date);

                if (s == null)
                {
                    return;
                }

                showIdStr = s.ShowId.ToString();
            }

            var showId = new Guid(showIdStr);

            IPhotoRepository photoRepo = new PhotoRepository(new PhishDatabase(new ConnectionString(new AppConfigManager(), connKey)));

            PhotoService photoService = new PhotoService(photoRepo);

            var photos = photoService.GetPhotosByShow(showId).Where(x => x.Thumbnail == false).ToList();

            if (photos == null || photos.Count <= 0)
            {
                final = GetNoImagesFound();
            }

            if (string.IsNullOrEmpty(final))
            {
                var json = new ImageJSONifier("records");

                foreach (var photo in photos)
                {
                    var path = (PhotoType)photo.Type != PhotoType.TicketStub ? ShowImagesFolder : TicketStubImagesFolder;

                    json.Add(new ImageItem
                    {
                        Image       = path + photo.FileName,
                        Description = photo.Notes,
                        Title       = photo.NickName,
                        //Thumb =  //This is a consideration.  If we want to go through the trouble of using the thumb or not
                    });
                }

                final = json.GetFinalizedJSON();
            }

            response.ContentType     = "application/json";
            response.ContentEncoding = Encoding.UTF8;
            response.Write(final);
        }
Esempio n. 33
0
 public ActionResult DeletePhoto(long photoId)
 {
     try
     {
         var photoRepo = new PhotoRepository();
         var photo = photoRepo.GetById(photoId);
         if (null != photo)
         {
             photoRepo.Remove(photo);
         }
     }
     catch (Exception e)
     {
         return Json(new { Status = "Failed", Description = e.Message });
     }
     return Json(new { Status = "OK", Description = "" });
 }
Esempio n. 34
0
 public PhotoController()
 {
     photoRepo = new PhotoRepository();
 }
Esempio n. 35
0
        public List <string> GetUnusedTagNames(long photoID)
        {
            var photoTags = PhotoRepository.Single(p => p.ID == photoID, p => p.Tags).Tags.Select(t => t.Name);

            return(TagRepository.GetAll().Select(t => t.Name).Except(photoTags).ToList());
        }
 public HomeController(PhotoRepository photoRepository)
 {
     repository = photoRepository;
 }
Esempio n. 37
0
 public SlideShow(List <Photo> photolist, KeywordRepository keywordRepository, PhotoRepository photoRepository, PhotoFileService photoFileService)
 {
     this.originalphotos      = photolist; //メイン画面から配列の受け取り
     this.sskeywordRepository = new KeywordRepository();
     this.ssphotoRepository   = new PhotoRepository();
     this.ssphotoFileService  = new PhotoFileService();
     this.application         = new PhotoFrameApplication(keywordRepository, photoRepository, photoFileService);
 }
Esempio n. 38
0
        protected void SeedDB()
        {
            IUserRepository userRepo = new UserRepository();


            if (userRepo.GetAllUsers().Count() < 1)
            {
                Guid userID = Guid.NewGuid();

                userRepo.AddUser(new Data.User {
                    Admin    = false,
                    Country  = "Sverige",
                    Email    = "*****@*****.**",
                    Password = "******",
                    Id       = userID,
                    Name     = "Mr. Test",
                });

                IAlbumRepository albumRepo = new AlbumRepository();

                Guid album1 = Guid.NewGuid();

                albumRepo.AddAlbum(new Data.Album
                {
                    Description = "+1 live-edge next level XOXO, ennui neutra vinyl hella. Scenester tofu selvage helvetica, fingerstache swag literally woke pinterest chicharrones jean shorts ennui kickstarter cronut. Salvia drinking vinegar hammock, helvetica lumbersexual retro franzen gochujang pabst. Deep v vice post-ironic umami, skateboard synth 8-bit mlkshk salvia street art neutra single-origin coffee food truck taxidermy. Coloring book listicle portland shabby chic prism, letterpress mumblecore.",
                    Name        = "Squid occupy celiac",
                    Id          = album1,
                    UserID      = userID
                });

                Guid album2 = Guid.NewGuid();

                albumRepo.AddAlbum(new Data.Album
                {
                    Description = "Fingerstache swag literally woke pinterest chicharrones jean shorts ennui kickstarter cronut. Salvia drinking vinegar hammock, helvetica lumbersexual retro franzen gochujang pabst. Deep v vice post-ironic umami, skateboard synth 8-bit mlkshk salvia street art neutra single-origin coffee food truck taxidermy. Coloring book listicle portland shabby chic prism, letterpress mumblecore.",
                    Name        = "single-origin coffee",
                    Id          = album2,
                    UserID      = userID
                });

                Guid album3 = Guid.NewGuid();

                albumRepo.AddAlbum(new Data.Album
                {
                    Description = "Kickstarter cronut. Salvia drinking vinegar hammock, helvetica lumbersexual retro franzen gochujang pabst. Deep v vice post-ironic umami, skateboard synth 8-bit mlkshk salvia street art neutra single-origin coffee food truck taxidermy. Coloring book listicle portland shabby chic prism, letterpress mumblecore.",
                    Name        = "Franzen jean shorts",
                    Id          = album3,
                    UserID      = userID
                });

                Guid album4 = Guid.NewGuid();

                albumRepo.AddAlbum(new Data.Album
                {
                    Description = "Helvetica lumbersexual retro franzen gochujang pabst. Deep v vice post-ironic umami, skateboard synth 8-bit mlkshk salvia street art neutra single-origin coffee food truck taxidermy. Coloring book listicle portland shabby chic prism, letterpress mumblecore.",
                    Name        = "Bag biodisel",
                    Id          = album4,
                    UserID      = userID
                });

                IPhotoRepository photoRepo = new PhotoRepository();
                var albums = albumRepo.GettAllAlbums();

                var photo = new Data.Photo {
                    Path        = " /Photos/1.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[0].Id
                };
                photoRepo.AddPhotoToDB(photo);

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/2.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[0].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/12.png",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[0].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/4.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[0].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/5.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[1].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/6.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[1].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/7.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[1].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/8.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[1].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/9.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[2].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/10.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[2].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/11.png",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[2].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/3.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[3].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/13.png",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[3].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/14.jpg",
                    Name        = "Freegan asymmetrical",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[3].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/15.png",
                    Name        = "Gentrify butcher selfies tacos",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[3].Id
                });

                photoRepo.AddPhotoToDB(new Data.Photo
                {
                    Path        = " /Photos/16.jpg",
                    Name        = "Gentrify butcher selfies tacos",
                    Description = "Freegan asymmetrical squid microdosing. Gentrify butcher selfies tacos, poke occupy mustache roof party brunch dreamcatcher glossier chicharrones green juice +1 semiotics. Kickstarter kinfolk sartorial narwhal, semiotics humblebrag brooklyn tumblr kale chips mumblecore.",
                    Date        = DateTime.Now,
                    UserID      = userID,
                    AlbumID     = albums[3].Id
                });
            }
        }
 public BildgalleriController()
 {
     PhotoRepository = new PhotoRepository();
 }
Esempio n. 40
0
 public AlbumController()
 {
     AlbumRepository = new AlbumRepository();
     PhotoRepository = new PhotoRepository();
 }
Esempio n. 41
0
 public void UpdatePhoto(Photo photo)
 {
     PhotoRepository.UpdatePhoto(photo);
 }
 public void Setup()
 {
     _mockClient = Substitute.For <ITypicodeClient>();
     _repository = new PhotoRepository(_mockClient);
 }
Esempio n. 43
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));
            }
        }