public static List<VideoEmbed> Load(int? id, string username, int? numberOfVideos) { List<VideoEmbed> videoEmbeds = new List<VideoEmbed>(); using (SqlConnection conn = Config.DB.Open()) { SqlDataReader reader = SqlHelper.ExecuteReader(conn, "LoadVideoEmbeds", id, username, numberOfVideos); while (reader.Read()) { VideoEmbed videoEmbed = new VideoEmbed(); videoEmbed.id = (int)reader["Id"]; videoEmbed.username = (string)reader["Username"]; videoEmbed.thumbUrl = (string)reader["ThumbUrl"]; videoEmbed.videoUrl = (string)reader["VideoUrl"]; videoEmbed.title = (string)reader["Title"]; videoEmbed.sourceType = (EmbedSourceType) reader["SourceType"]; videoEmbeds.Add(videoEmbed); } } return videoEmbeds; }
protected void btnEmbedVideo_Click(object sender, EventArgs e) { string thumbUrl = (string)ViewState["UploadVideo_ThumbUrl"]; string videoUrl = (string)ViewState["UploadVideo_VideoUrl"]; string title = (string)ViewState["UploadVideo_Title"]; VideoEmbed embed = new VideoEmbed(((PageBase)Page).CurrentUserSession.Username, videoUrl); embed.ThumbUrl = thumbUrl; embed.Title = title; embed.Save(); #region Add NewFriendYouTubeUpload Event Event newEvent = new Event(embed.Username); newEvent.Type = Event.eType.NewFriendYouTubeUpload; NewFriendYouTubeUpload newFriendYouTubeUpload = new NewFriendYouTubeUpload(); newFriendYouTubeUpload.YouTubeUploadID = embed.Id; newEvent.DetailsXML = Misc.ToXml(newFriendYouTubeUpload); newEvent.Save(); string[] usernames = Classes.User.FetchMutuallyFriends(embed.Username); foreach (string friendUsername in usernames) { if (Config.Users.NewEventNotification) { if (CurrentUserSession != null) { string text = String.Format("Your friend {0} has uploaded a new video".Translate(), "<b>" + CurrentUserSession.Username + "</b>"); int imageID = 0; try { imageID = Photo.GetPrimary(CurrentUserSession.Username).Id; } catch (NotFoundException) { imageID = ImageHandler.GetPhotoIdByGender(CurrentUserSession.Gender); } string thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true); Classes.User.SendOnlineEventNotification(embed.Username, friendUsername, text, thumbnailUrl, UrlRewrite.CreateShowUserUrl(embed.Username)); } } } #endregion ShowEmbeddedVideos(); }