Пример #1
0
        public override PhotoResourceDto Persist(PhotoResourceDto photoResourceDto)
        {
            Gallery gallery = _galleryDao.FindSingle(new GalleryFilterDto()
            {
                OwnerId = photoResourceDto.UserDefinableOwnerId
            });
            bool automaticCoverPhotoSet = false;

            if (gallery == null)
            {
                gallery = CreateAndPersistEmptyProfileGallery(photoResourceDto.UserDefinableOwnerId);
                automaticCoverPhotoSet = true;
            }
            photoResourceDto.UserDefinableId = gallery.Id;
            PhotoThumbnailInfo photoThumbnailInfo = PhotoThumbnailInfoProvider.GetDefault(photoResourceDto.OwnerType);

            photoResourceDto.Path = string.Format(photoThumbnailInfo.Path, photoResourceDto.UserDefinableOwnerId, photoResourceDto.UserDefinableId);
            photoResourceDto      = base.Persist(photoResourceDto);
            if (automaticCoverPhotoSet)
            {
                gallery.CoverPhotoId = photoResourceDto.Id;
                _genericDao.Persist <Gallery>(gallery);
            }
            return(photoResourceDto);
        }
Пример #2
0
        private IList <ValidationResult> IsImage(PhotoResourceDto photoResourceDto)
        {
            IList <ValidationResult> validationResults = new List <ValidationResult>();

            try
            {
                using (Image image = Image.FromStream(photoResourceDto.Stream, false, false))
                {
                    PhotoThumbnailInfo photoThumbnailInfo = PhotoThumbnailInfoProvider.GetDefault(photoResourceDto.OwnerType);
                    if (photoThumbnailInfo.MinimumHeight < image.Height || photoThumbnailInfo.MinimumWidth < image.Width)
                    {
                        validationResults.Add(new ValidationResult(MessageKeyConstants.VALIDATION_IMAGE_MINIMUM_SIZE_MESSAGE, image.Width, image.Height, photoThumbnailInfo.MinimumWidth, photoThumbnailInfo.MinimumHeight));
                    }
                    return(validationResults);
                }
            }
            catch
            {
                validationResults.Add(new ValidationResult(MessageKeyConstants.VALIDATION_FILE_IS_IN_WRONG_FORMAT_MESSAGE, "Image"));
            }
            return(validationResults);
        }
Пример #3
0
 public GalleryDto(Type type)
 {
     PhotoThumbnailInfo = PhotoThumbnailInfoProvider.GetDefault(type);
 }
Пример #4
0
        private Size GetMaximumPhotoSize(PhotoResourceDto photoResourceDto)
        {
            PhotoThumbnailInfo photoThumbnailInfo = PhotoThumbnailInfoProvider.GetDefault(photoResourceDto.OwnerType);

            return(new Size(photoThumbnailInfo.MinimumWidth, photoThumbnailInfo.MinimumHeight));
        }