/// <summary> /// Updates the photos with apply action. /// </summary> /// <param name="postView">The post view.</param> private void UpdatePhotosWithApplyAction(ManagePhotoPostView postView) { MediaStatus mediaStatus = postView.MediaStatus.ParseEnum <MediaStatus>(); if (postView.MediaId != null && postView.MediaId.Length > 0) { mediaRepository.UpdateStatus(postView.MediaId, user.Id, mediaStatus); } }
/// <summary> /// Renders the view. /// </summary> /// <returns></returns> public ManagePhotosView RenderView(string view, ManagePhotoPostView postView, Func <List <Media> > retrieve) { ManagePhotosView managePhotosView = RenderMedia(postView, retrieve, "ManagedPhotoView"); managePhotosView.BreadCrumbs = SetBreadCrumb(view); managePhotosView.TabName = view; managePhotosView.RenderAdminTags = _tagService.HyperlinkTheAdminTags; return(managePhotosView); }
/// <summary> /// Gets the view. /// </summary> /// <param name="viewLink">The view link.</param> /// <param name="postView">The post view.</param> /// <param name="retrieveMedia">The retrieve media.</param> /// <param name="user">The user.</param> /// <param name="authorization">The authorization.</param> /// <returns></returns> public ManagePhotosView GetView(string viewLink, ManagePhotoPostView postView, Func <List <Media> > retrieveMedia, Domain.Model.User user, Authorization authorization) { IEnumerable <IRenderManagePhotoView> photoViews = Implementions(user, authorization); IRenderManagePhotoView view = new GetManagePhotoView(user, _tagService, authorization); foreach (IRenderManagePhotoView photoView in photoViews.Where(photoView => string.Equals(photoView.ButtonName, postView.Submit, StringComparison.InvariantCultureIgnoreCase))) { view = photoView; break; } return(view.RenderView(viewLink, postView, retrieveMedia)); }
/// <summary> /// Photoes the view. /// </summary> /// <param name="viewLink">The view link.</param> /// <param name="postView">The post view.</param> /// <param name="media">The media.</param> /// <returns></returns> public ActionResult PhotoView(string viewLink, ManagePhotoPostView postView, List <Media> media) { int page = (string.IsNullOrEmpty(postView.CP) ? 1 : Convert.ToInt32(postView.CP)); string queryValues = (string.IsNullOrEmpty(postView.Text) ? "?cp=" + page : "?cp=" + page + "&text=" + HttpUtility.HtmlEncode(postView.Text)); ManagePhotosView view = GetManagePhotoView(viewLink, postView, () => media); view = SetAuthorizationAndUrlService(view); view.Set = persistentCollectionService.Set(Authorization.Owner.Username + "Photos" + viewLink + "_" + postView.Text, media, Persistence.Permanent); persistentCollectionService.SetBackUrl(Authorization.Owner.Username + "/photos/" + viewLink + "/" + queryValues, SiteCookie); return(View("Index", view)); }
public ActionResult Search(ManagePhotoPostView postView) { List <Media> search = new List <Media>(); if (postView != null && !string.IsNullOrEmpty(postView.Text)) { search = _mediaRepository.SearchByTextAndUserId(postView.Text, Owner.Id); } // ReSharper disable PossibleNullReferenceException postView.Submit = "search"; // ReSharper restore PossibleNullReferenceException return(PhotoView("search", postView, search)); }
/// <summary> /// Renders the view. /// </summary> /// <param name="viewLink">The view link.</param> /// <param name="postView">The post view.</param> /// <param name="retrieve"></param> /// <returns></returns> public ManagePhotosView RenderView(string viewLink, ManagePhotoPostView postView, Func <List <Media> > retrieve) { AddTagsToMedia(postView); ManagePhotosView managePhotosView = RenderMedia(postView, retrieve, "ManagedPhotoView"); managePhotosView.UIMessage = (postView.MediaId != null ? string.Format("Tags were successfully added to {0} photo(s)", postView.MediaId.Length) : string.Empty); managePhotosView.BreadCrumbs = SetBreadCrumb(viewLink); managePhotosView.TabName = viewLink; managePhotosView.RenderAdminTags = _tagService.HyperlinkTheAdminTags; managePhotosView.Authorization = authorization; return(managePhotosView); }
/// <summary> /// Renders the apply action. /// </summary> /// <param name="postView">The post view.</param> /// <param name="retrieve">The retrieve.</param> /// <param name="viewName">Name of the view.</param> /// <param name="format">The format.</param> /// <returns></returns> protected ManagePhotosView RenderMedia(ManagePhotoPostView postView, Func <List <Media> > retrieve, string viewName, string format) { ManagePhotosView view = new ManagePhotosView(); List <Media> media = retrieve(); int index = (string.IsNullOrEmpty(postView.CP) ? 1 : Convert.ToInt32(postView.CP)); view.MediaStatusCount = mediaRepository.GetMediaStatusCountByUserId(user.Id); view.Pagination = _paginationService; view.TotalResults = media.Count; view.PartialView = viewName; view.UIMessage = string.Empty; view.Authorization = authorization; view.Pagination.GeneratePaging(media, index, 20, format); return(view); }
/// <summary> /// Adds the tags to media. /// </summary> /// <param name="postView">The post view.</param> private void AddTagsToMedia(ManagePhotoPostView postView) { TagCollection tagCollection = new TagCollection(postView.Tags); List <Media> mediae = mediaRepository.RetrieveByMediaIds(postView.MediaId, user.Id); if (postView.MediaId != null) { foreach (int id in postView.MediaId) { int mediaId = id; Media media = mediae.Where(o => mediaId == o.MediaId).First(); TagCollection currentTags = new TagCollection(media.Tags); IEnumerable <Tag> newTags = JoinTags(tagCollection, currentTags); media.AddTags(newTags); _updateTagService.UpdateTags(media.Tags, mediaId, user); } } }
/// <summary> /// Renders the view. /// </summary> /// <param name="view">The view.</param> /// <param name="postView">The post view.</param> /// <param name="retrieve">The retrieve.</param> /// <returns></returns> public ManagePhotosView RenderView(string view, ManagePhotoPostView postView, Func <List <Media> > retrieve) { UpdatePhotosWithApplyAction(postView); ManagePhotosView managePhotosView = RenderMedia(postView, retrieve, "ManagedPhotoView"); managePhotosView.RenderAdminTags = _tagService.HyperlinkTheAdminTags; managePhotosView.BreadCrumbs = SetBreadCrumb(view); CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; string viewName = cultureInfo.TextInfo.ToTitleCase(postView.MediaStatus); string friendlyViewName = (string.Equals(viewName, "Innetwork", StringComparison.InvariantCultureIgnoreCase) ? "In Network" : viewName); if (postView.MediaId != null && postView.MediaId.Length > 0) { managePhotosView.UIMessage = string.Format("{0} photo(s) moved to {1}.", postView.MediaId.Length, friendlyViewName); } managePhotosView.TabName = view; return(managePhotosView); }
/// <summary> /// Gets the manage photo view. /// </summary> /// <param name="view">The view.</param> /// <param name="managePhotoPostView">The manage photo post view.</param> /// <param name="retreiveMedia">The retreive media.</param> /// <returns></returns> private ManagePhotosView GetManagePhotoView(string view, ManagePhotoPostView managePhotoPostView, Func <List <Media> > retreiveMedia) { return(_managePhotoService.GetView(view, managePhotoPostView, retreiveMedia, Owner, Authorization)); }
public ActionResult Index(ManagePhotoPostView postView) { List <Media> list = _mediaRepository.RetrievePublic(Owner.Id); return(PhotoView("public", postView, list)); }
public ActionResult Private(ManagePhotoPostView postView) { List <Media> list = _mediaRepository.RetrievePrivate(Owner.Id); return(PhotoView("private", postView, list)); }
public ActionResult InNetwork(ManagePhotoPostView postView) { List <Media> list = _mediaRepository.RetrieveInNetwork(Owner.Id); return(PhotoView("innetwork", postView, list)); }
public ActionResult Public(ManagePhotoPostView postView) { List <Media> media = _mediaRepository.RetrievePublic(Owner.Id); return(PhotoView("public", postView, media)); }
/// <summary> /// Renders the media. /// </summary> /// <param name="postView">The post view.</param> /// <param name="retrieve">The retrieve.</param> /// <param name="viewName">Name of the view.</param> /// <returns></returns> protected ManagePhotosView RenderMedia(ManagePhotoPostView postView, Func <List <Media> > retrieve, string viewName) { return(RenderMedia(postView, retrieve, viewName, "?cp={0}")); }