/// <summary> /// Gets the join tags. /// </summary> /// <param name="newCollection">The new collection.</param> /// <param name="currentCollection">The current collection.</param> /// <returns></returns> private static IEnumerable<Tag> JoinTags(TagCollection newCollection, TagCollection currentCollection) { return (from tag in newCollection.Tags let tag1 = tag let found = currentCollection.Tags.Any(media1 => string.Equals(media1.TagText, tag1.TagText, StringComparison.InvariantCultureIgnoreCase)) where !found select tag).ToList(); }
/// <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; }
/// <summary> /// Retrieves the photos that do not include photos from album id and user id. /// </summary> /// <param name="albumId">The album id.</param> /// <param name="userId">The user id.</param> /// <param name="tagCollection">The tag collection.</param> /// <returns></returns> public List<Media> SearchTagsForPhotosThatDoNotIncludePhotosFromAlbumIdAndUserId(int albumId, int userId, TagCollection tagCollection) { DataTable tags = new DataTable(); tags.Columns.Add("tag"); foreach (Tag tag in tagCollection.Tags) { DataRow row = tags.NewRow(); row["tag"] = tag.TagText; tags.Rows.Add(row); } List<Media> collection = database.PopulateCollection("Media_SearchTagsForPhotosThatDoNotIncludePhotosFromAlbumIdAndUserID", new { albumId, userId, tags }, database.AutoPopulate<Media>); _hydrationService.Populate(collection); return collection; }
public string GenerateLinks(TagCollection tagCollection) { const string linkFormat = @"<a href="""" title=""""> </a>"; return linkFormat; }
/// <summary> /// Updates the specified post. /// </summary> /// <param name="tags">The tags.</param> /// <param name="mediaId">The media id.</param> public void Update(string tags, int mediaId) { TagCollection internalTags = new TagCollection(tags); database.NonQuery("Tag_DeleteTagsByMediaId", new{mediaId}); foreach (Tag tag in internalTags) { InsertTagWithMediaId(tag, mediaId); } }
/// <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); } } }