コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaJson"/> class.
 /// </summary>
 /// <param name="media">The media.</param>
 public MediaJson(Media media)
 {
     MediaId = media.MediaId;
     CommentCount = media.CommentCount;
     CreateDate = media.CreateDate;
     Day = media.Day;
     Description = media.Description;
     Month = media.Month;
     Status = media.Status;
     Title = media.Title;
     UserId = media.Owner.UserId;
     Username = media.Owner.Username;
     Year = media.Year;
 }
コード例 #2
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public string JustTheImageWebsize(Media media)
        {
            MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail);
            MediaFile websize = media.GetImageByPhotoType(PhotoType.Websize);

            const string linkFormat = "<a class=\"popupimage\" href=\"{0}\" name=\"{4}\" title=\"{1}\"><img src=\"{2}\" alt=\"{3}\" /></a>";
            string link = string.Format(linkFormat,
                                        UrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, websize.FilePath),
                                        media.Title,
                                       UrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, thumbnail.FilePath),
                                        media.Description, media.MediaId);

            return link;
        }
コード例 #3
0
        /// <summary>
        /// Retrieves the type of the by media.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="photoType">Type of the photo.</param>
        /// <returns></returns>
        private static MediaFile RetrieveByMediaType(Media media, PhotoType photoType)
        {
            MediaFile mediaFile = new MediaFile();

            foreach (MediaFile file in media.MediaFiles)
            {
                if (file.PhotoType == photoType)
                {
                    mediaFile = file;
                    break;
                }
            }

            return mediaFile;
        }
コード例 #4
0
        /// <summary>
        /// Grayscales the specified id.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public ActionResult Grayscale(Media media)
        {
            MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail);
            byte[] fileBytes = _imageService.GetFileBytes(thumbnail, Owner);
            string contentType = _imageService.GetContentType(thumbnail);
            Bitmap bitmap = _imageConverter.ConvertByteArrayToBitmap(fileBytes);
            Bitmap grayScale = _imageConverter.ConvertToGrayScale(bitmap);

            byte[] grayScaleBytes = _imageConverter.ConvertBitmaptoBytes(grayScale, ImageFormat.Jpeg);

            bitmap.Dispose();
            grayScale.Dispose();

            return File(grayScaleBytes, contentType);
        }
コード例 #5
0
        /// <summary>
        /// Updates the details.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="batchId">The batch id.</param>
        public void UpdateDetails(Media media, Guid batchId)
        {
            UploadBatch batch = _mediaQueueRepository.GetUploadBatch(batchId);
            AddMediaToAlbum(batch, media.MediaId);
            _mediaQueueRepository.InsertBatchIdAndMediaId(batchId, media.MediaId);

            media.Tags = batch.Tags;
            media.Day = (batch.Day ?? media.Day);
            media.Month = (batch.Month ?? media.Month);
            media.Year = (batch.Year ?? media.Year);
            media.Status = batch.MediaStatus.ParseEnum<MediaStatus>();
            _mediaRepository.Save(media);

            _uploaderMediaRepository.UpdateMediaStatus(media.MediaId, MediaUploadState.Queued);
            SaveLocation(batch, media.Owner.UserId);
        }
コード例 #6
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="set">The set.</param>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public static string GetImageLink(string set, Media media)
        {
            MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail);
            MediaFile websize = media.GetImageByPhotoType(PhotoType.Websize);
            IUserUrlService userUrlService = GetUserUrlService();

            const string linkFormat = "<a id=\"{4}\" class=\"showimage lightbox\" name=\"{3}\" rel=\"{2}\" href=\"{5}\" title=\"{1}\"><img src=\"{0}\" alt=\"{1}\" /></a>";
            string link = string.Format(linkFormat,
                                        userUrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, thumbnail.FilePath),
                                        media.Title,
                                        userUrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, websize.FilePath),
                                        media.MediaId,
                                        media.Owner.Username,
                                        userUrlService.UserUrl(media.Owner.Username, "photos/show/" + set + "/#/photo/" + media.MediaId));

            return link;
        }
コード例 #7
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="cssClass">The CSS class.</param>
        /// <param name="set">The set.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static string GetImageDetailLinkForFirst(Media media, string cssClass, string set, PhotoType type)
        {
            IUserUrlService userUrlService = GetUserUrlService();
            Func<string, string> title =
                s => (string.IsNullOrEmpty(media.Title)
                     ? string.Empty
                     : string.Format("title=\"{0} - {1} {2}\"", media.Title, media.Owner.FirstName, media.Owner.LastName));

            MediaFile thumbnail = media.GetImageByPhotoType(type);
            const string linkFormat = "<a class=\"{5} lightbox\" name=\"{6}\"  href=\"{0}\" {1} ><img src=\"{2}\" alt=\"{3}\" {4} /></a>";
            string link = string.Format(linkFormat,
                userUrlService.UserUrl(media.Owner.Username, "photos/show/" + set + "/#/photo/" + media.MediaId),
                title(media.Title),
                userUrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath),
                media.Title,
                title(media.Title),
                cssClass,
                media.MediaId);

            return link;
        }
コード例 #8
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public string GetImageLink(Media media)
        {
            Func<string, string> title =
                s => (string.IsNullOrEmpty(media.Title)
                     ? string.Empty
                     : string.Format("title=\"{0} - {1} {2}\"", media.Title, media.Owner.FirstName, media.Owner.LastName));

            MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail);
            MediaFile websize = media.GetImageByPhotoType(PhotoType.Websize);
            const string linkFormat = "<a class=\"{5}\" id=\"{7}\" name=\"{6}\" rel=\"{0}\" href=\"{8}\" {1} ><img src=\"{2}\" alt=\"{3}\" {4} /></a>";
            string link = string.Format(linkFormat,
                UrlService.CreateImageUrl(media.Owner.Username, websize.FilePath),
                title(media.Title),
                UrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath),
                media.Title,
                title(media.Title),
                "lightbox showimage",
                media.MediaId,
                media.Owner.Username,
                UrlService.UserUrl(media.Owner.Username, "photos/show/#/photo/" + media.MediaId));

            return link;
        }
コード例 #9
0
 /// <summary>
 /// Gets the image link.`
 /// </summary>
 /// <param name="set">The set.</param>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public string GetImageLink(string set, Media media)
 {
     return PhotoHtmlHelper.GetImageLink(set, media);
 }
コード例 #10
0
        public ActionResult Edit(Media media, SavedPhotoView savedPhotoView)
        {
            media = Mapper.Map(savedPhotoView, media);
            _mediaRepository.Save(media);

            EditPhotoView view = new EditPhotoView { UIMessage = "Photo details saved."};
            view = SetAuthorizationAndUrlService(view);
            return View(view);
        }
コード例 #11
0
        public ActionResult Leave(Media media)
        {
            List<Comment> comments = _commentRepository.RetrieveAllByMediaId(media.MediaId);
            IDictionary<string, string> crumb = CommentCrumb(media, media.MediaId);

            CommentsView commentsView = ModelFactory<CommentsView>(new { media, comments });
            return View(commentsView, crumb);
        }
コード例 #12
0
 /// <summary>
 /// Fullsizes the specified media id.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public ActionResult Medium(Media media)
 {
     MediaFile fullsizeFile = media.GetImageByPhotoType(PhotoType.Websize);
     return GetFile(fullsizeFile);
 }
コード例 #13
0
        /// <summary>
        /// Inserts Media into the Medias Table
        /// </summary>
        /// <param name="media">A new populated media.</param>
        /// <returns>Insert Count</returns>
        private int Insert(Media media)
        {
            DbParameter outParameter = database.MakeParameter("@Identity", 0, ParameterDirection.Output);
            List<DbParameter> parameters = new List<DbParameter>
            {
                    database.MakeParameter("@Title",media.Title),
                    database.MakeParameter("@Description",media.Description),
                    database.MakeParameter("@MediaMonth",media.Month),
                    database.MakeParameter("@MediaYear",media.Year),
                    database.MakeParameter("@MediaDay",media.Day),
                    database.MakeParameter("@UserId",media.Owner.UserId),
                    database.MakeParameter("@Status",media.Status.ToString()),
                    database.MakeParameter("@Tags",media.Tags),
                    outParameter
            };

            database.NonQuery("Media_Insert", parameters);
            int id = Convert.ToInt32(outParameter.Value);

            foreach (MediaFile file in media.MediaFiles)
            {
                file.MediaId = id;
                _mediaFileRepository.Save(file);
            }

            TagCollection interalTagCollection = new TagCollection(media.Tags);
            foreach (Tag tag in interalTagCollection.Tags)
            {
                _tagRepository.InsertTagWithMediaId(tag, id);
            }

            return id;
        }
コード例 #14
0
        /// <summary>
        /// Gets the random album image.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        private string GetRandomAlbumImage(Media media)
        {
            string randomImageLink = UrlService.CreateRootUrl("content/images/nophotosfound.png");

            if (media != null)
            {
                string filePath = media.GetImageByPhotoType(PhotoType.Thumbnail).FilePath;

                if (!string.IsNullOrEmpty(filePath))
                {
                    randomImageLink = UrlService.CreateImageUrl(filePath);
                }

            }

            return randomImageLink;
        }
コード例 #15
0
 /// <summary>
 /// Gets the media details.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public string GetMediaDetails(Media media)
 {
     return string.Format("{0}{1}<p style=\"margin-bottom:0px;\" >tags: {2}", string.Format("<strong style=\"font-size:11px;color:#bbb;\">{0}</strong>", media.Title), string.Format("<p>{0}</p>", media.Description), HyperlinkTags(media.Tags, media.Owner.Username));
 }
コード例 #16
0
        /// <summary>
        /// Gets the image HTML.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public string GetImageHtml(Media media)
        {
            const string htmlFormat = @"<img alt=""{0}"" id=""image"" src=""{1}"">";

            MediaFile mediaFile = media.GetImageByPhotoType(PhotoType.Websize);
            return string.Format(htmlFormat, media.Title, UrlService.CreateImageUrl(mediaFile.FilePath));
        }
コード例 #17
0
 /// <summary>
 /// Gets the media.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public JsonResult Details(Media media)
 {
     string linkHtml = PhotoHtmlHelper.GetPhotoDetailLinks(media, Authorization.IsOwner);
     return Json(new { detailHtml = linkHtml, mediaTitle = media.Title, mediaDescription = media.Description }, "application/json", JsonRequestBehavior.AllowGet);
 }
コード例 #18
0
        /// <summary>
        /// Gets the photo detail links.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="isAuthenticated">if set to <c>true</c> [is authenticated].</param>
        /// <returns></returns>
        private string GetDetailSection(Media media, bool isAuthenticated)
        {
            ITagService tagService = DependencyInjection.Resolve<ITagService>();

            string html = @"<ul>
                        <li>
                        <span>";
            html += (isAuthenticated ? @"<a id=""editlink""  href=""{0}/photos/edit/{1}"">edit</a>" : string.Empty);
            html += @"</span>
                    </li>";
            html += "{2}";
            html += @"
                    </li>
                     {3}
                    <li><span><a href=""{0}/comments/leave/{1}"">comments ({4})</a></span>
                </ul>";

            string tags = string.Empty;
            if (!string.IsNullOrEmpty(media.Tags))
            {
                const string tagFormat = @"<li><span>tags:</span> {0}</li>";
                string renderedTags = tagService.HyperlinkTheTags(media.Tags, media.Owner.Username);
                tags = string.Format(tagFormat, renderedTags);
            }

            string date = PhotoHtmlHelper.GetDate(media);
            string content = string.Format(html, UrlService.UserRoot(media.Owner.Username), HttpUtility.HtmlEncode(media.MediaId.ToString()), date, tags, media.CommentCount); return content;
        }
コード例 #19
0
 /// <summary>
 /// Fullsizes the specified media id.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public ActionResult Small(Media media)
 {
     MediaFile fullsizeFile = media.GetImageByPhotoType(PhotoType.Thumbnail);
     return GetFile(fullsizeFile);
 }
コード例 #20
0
 /// <summary>
 /// Rotates the right.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public ActionResult RotateRight(Media media)
 {
     int status = Rotate(media, _rotateService.RotateRight);
     return Content(status.ToString());
 }
コード例 #21
0
 /// <summary>
 /// Metas the specified id.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public ActionResult Meta(Media media)
 {
     string content = PhotoHtmlHelper.GetPhotoDetailLinks(media, Authorization.IsOwner);
     return Content(content);
 }
コード例 #22
0
 /// <summary>
 /// Renders the details.
 /// </summary>
 /// <param name="m">The m.</param>
 /// <returns></returns>
 public string RenderDetails(Media m)
 {
     return string.Format("<span class=\"title\" >{0}</span>", m.Title) +
      string.Format("<p>{0}</p>", m.Description) + (string.IsNullOrEmpty(m.Tags) ? string.Empty : "<p style=\"margin-bottom:0px;\" >tags:" + RenderAdminTags(m.Tags, Authorization.Owner.Username, m.MediaId) + " </p>");
 }
コード例 #23
0
 /// <summary>
 /// Renders the edit links.
 /// </summary>
 /// <param name="m">The m.</param>
 /// <returns></returns>
 public string RenderEditLinks(Media m)
 {
     return string.Format("<a class=\"delete\" name=\"{1}\" style='float: right;margin-right:10px;' href=\"/{0}/photos/delete/{1}\" title=\"delete photo\"><img style='background-color:transparent;border:none;' src='/content/images/cancel.png' alt='delete photo' /></a>", Authorization.Owner.Username, m.MediaId) +
          string.Format("<a class=\"edit\" name=\"{1}\" style='float: right;margin-right:30px;' href=\"/{0}/photos/edit/{1}\" title=\"edit photo\"><img style='background-color:transparent;border:none;' src='/content/images/pencil.png' alt='edit' /></a>", Authorization.Owner.Username, m.MediaId);
 }
コード例 #24
0
 /// <summary>
 /// Fullsizes the specified media id.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public ActionResult Fullsize(Media media)
 {
     MediaFile fullsizeFile = media.GetImageByPhotoType(PhotoType.Original);
     return GetFile(fullsizeFile);
 }
コード例 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaComments"/> class.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <param name="comment">The comment.</param>
 public MediaComments(Media media, Comment comment)
 {
     Media = media;
     Comment = comment;
 }
コード例 #26
0
 /// <summary>
 /// Gets the image SRC.
 /// </summary>
 /// <returns></returns>
 public string GetImageSrc(Media media, PhotoType type)
 {
     MediaFile webSize = media.GetImageByPhotoType(type);
     string url = UrlService.CreateImageUrl(media.Owner.Username, webSize.FilePath);
     return url;
 }
コード例 #27
0
 /// <summary>
 /// Saves the specified media.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public int Save(Media media)
 {
     int id = media.MediaId > 0 ? Update(media) : Insert(media);
     return id;
 }
コード例 #28
0
        /// <summary>
        /// Sets the bread crumb.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="photoId">The photo id.</param>
        /// <returns></returns>
        public IDictionary<string, string> CommentCrumb(Media media, int photoId)
        {
            IDictionary<string, string> crumbs = SetBreadCrumb(new KeyValuePair<string, string>((string.IsNullOrEmpty(media.Title) ? "Untitled" : media.Title), UrlService.UserUrl(string.Format("photos/show/#/photo/{0}", photoId))));
            crumbs.Add("Comments", UrlService.UserUrl(string.Format("comments/leave/{0}", photoId)));

            return crumbs;
        }
コード例 #29
0
        /// <summary>
        /// Updates the Media table by the primary key, if the Media is dirty then an update will occur
        /// </summary>
        /// <param name="media">a populated media</param>
        /// <returns>update count</returns>
        private int Update(Media media)
        {
            List<DbParameter> parameters = new List<DbParameter>
                {
                    database.MakeParameter("@MediaId",media.MediaId),
                    database.MakeParameter("@Title",media.Title),
                    database.MakeParameter("@Description",media.Description),
                    database.MakeParameter("@MediaMonth",media.Month),
                    database.MakeParameter("@MediaYear",media.Year),
                    database.MakeParameter("@MediaDay",media.Day),
                    database.MakeParameter("@UserId",media.Owner.UserId),
                    database.MakeParameter("@Status",media.Status.ToString()),
                    database.MakeParameter("@Tags",media.Tags),
                    database.MakeParameter("@LocationName",media.Location.LocationName),
                    database.MakeParameter("@Latitude",media.Location.Latitude),
                    database.MakeParameter("@Longitude",media.Location.Longitude),
                    database.MakeParameter("@Zoom",media.Location.Zoom),
                    database.MakeParameter("@MapTypeId",media.Location.MapTypeId)
                };

            database.NonQuery("Media_Update", parameters);
            _tagRepository.Update(media.Tags, media.MediaId);

            return 0;
        }
コード例 #30
0
        /// <summary>
        /// Gets the media.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public JsonResult GetDetails(Media media)
        {
            MediaFile file = media.GetImageByPhotoType(PhotoType.Websize);
            string imageSrc = UrlService.CreateImageUrl(file.FilePath);
            string details = GetDetailSection(media, Authorization.IsOwner);

            Resizer resizer = new Resizer();
            resizer.Resize(file.Width, file.Height, Authorization.Owner.Settings.WebViewMaxWidth, Authorization.Owner.Settings.WebViewMaxHeight);

            return Json(new { imageSrc, media.Title, media.Description, details, Authorization.Owner.DisplayName, resizer.Width, resizer.Height }, "application/json");
        }