public ActionResult AddNewChartPage(string text_AddNewChart_ChartName, string text_AddNewChart_chartGuid) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.DynamicContent dynCont = new hypster_tv_DAL.DynamicContent(); dynCont.DynCont_Name = text_AddNewChart_ChartName; dynCont.DynCont_isNameVisible = false; dynCont.DynCont_BoxCont = generate_Chart(text_AddNewChart_chartGuid); dynCont.DynCont_ButtonText = "Listen Now"; dynCont.DynCont_Href = ""; dynCont.DynCont_isNewWindow = false; dynCont.DynCont_PageType = 1; hyDB.DynamicContents.AddObject(dynCont); hyDB.SaveChanges(); return(RedirectPermanent("/WebsiteManagement/hypDynamicContent")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult ContactUs(string YourEmail, string Subject, string Message, bool captchaValid, string captchaErrorMessage) { if (captchaValid) { hypster_tv_DAL.Hypster_Entities HypDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.userContact userContact = new hypster_tv_DAL.userContact(); userContact.contactType = 1; userContact.contactEmail = YourEmail; userContact.contactSubject = Subject; userContact.contactText = Message; HypDB.userContacts.AddObject(userContact); HypDB.SaveChanges(); hypster_tv_DAL.Email_Manager emailManager = new hypster_tv_DAL.Email_Manager(); emailManager.SendContactUsEmail("*****@*****.**", "*****@*****.**", "*****@*****.**", Subject, YourEmail, Message); return(View("ContactsThanks")); } return(View("ContactUs")); }
public ActionResult SubmitVideoComment(hypster_tv_DAL.videoComment p_comment, string video_guid) { hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); p_comment.comment = System.Text.RegularExpressions.Regex.Replace(p_comment.comment, @"<(.|\n)*?>", string.Empty); p_comment.ipAddress = IpAddress(); p_comment.status = (int)hypster_tv_DAL.newsCommentStatus.NoActive; p_comment.user_ID = memberManager.getMemberByUserName(User.Identity.Name).id; p_comment.userName = User.Identity.Name; p_comment.postDate = DateTime.Now; hyDB.videoComments.AddObject(p_comment); hyDB.SaveChanges(); //need to reset data cache (if exist) // this will allow to show new comment System.Runtime.Caching.ObjectCache i_chache = System.Runtime.Caching.MemoryCache.Default; if (i_chache["VideoComment_For_Tv_" + p_comment.videoClip_ID] != null) { i_chache.Remove("VideoComment_For_Tv_" + p_comment.videoClip_ID); } return(RedirectToAction("getVideo", "video", new { @video_id = video_guid })); }
public ActionResult AddNewDynPage(int dr_dynPageType, string text_BoxName, string text_BoxCont) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.DynamicContent dynCont = new hypster_tv_DAL.DynamicContent(); dynCont.DynCont_Name = text_BoxName; dynCont.DynCont_isNameVisible = false; dynCont.DynCont_BoxCont = text_BoxCont; dynCont.DynCont_ButtonText = "Listen Now"; dynCont.DynCont_Href = "http://hypster.com"; dynCont.DynCont_isNewWindow = false; dynCont.DynCont_PageType = dr_dynPageType; hyDB.DynamicContents.AddObject(dynCont); hyDB.SaveChanges(); return(RedirectPermanent("/WebsiteManagement/hypDynamicContent")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult AddNewCloneChart(string ChartGuid, string ChartName, string ChartDesc, string ChartDate, int UserID, string existingChartGuid) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.chartsManager chartManager = new hypster_tv_DAL.chartsManager(); hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); if (chartManager.GetChartByGuid(ChartGuid).Chart_ID == 0) { //create cloned chart hypster_tv_DAL.Chart newClonedChart = new hypster_tv_DAL.Chart(); newClonedChart.Chart_GUID = ChartGuid; newClonedChart.Chart_Name = ChartName; newClonedChart.Chart_Desc = ChartDesc; newClonedChart.Chart_Date = ChartDate; newClonedChart.Chart_User_ID = UserID; //get existing chart hypster_tv_DAL.Chart existing_chart = new hypster_tv_DAL.Chart(); existing_chart = chartManager.GetChartByGuid(existingChartGuid); //get existing songs for cloning List <hypster_tv_DAL.PlaylistData_Song> existing_songs = new List <hypster_tv_DAL.PlaylistData_Song>(); existing_songs = playlistManager.GetSongsForPlayList((int)existing_chart.Chart_User_ID, (int)existing_chart.Chart_Playlist_ID); //clone playlist hypster_tv_DAL.Playlist existing_playlist = new hypster_tv_DAL.Playlist(); existing_playlist = playlistManager.GetUserPlaylistById((int)existing_chart.Chart_User_ID, (int)existing_chart.Chart_Playlist_ID); hypster_tv_DAL.Playlist new_playlist = new hypster_tv_DAL.Playlist(); new_playlist.create_time = 0; new_playlist.is_artist_playlist = false; new_playlist.name = existing_playlist.name + " CLONE"; new_playlist.update_time = 0; new_playlist.userid = existing_playlist.userid; new_playlist.ViewsNum = 0; new_playlist.Likes = 0; int new_playlist_id = playlistManager.AddNewPlaylist(new_playlist); //assign to chart new cloned playlist newClonedChart.Chart_Playlist_ID = new_playlist_id; //clone songs List <hypster_tv_DAL.PlaylistData_Song> new_songs = new List <hypster_tv_DAL.PlaylistData_Song>(); hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); foreach (var item in existing_songs) { hypster_tv_DAL.PlaylistData song = new hypster_tv_DAL.PlaylistData(); song.playlist_id = new_playlist_id; song.userid = new_playlist.userid; song.sortid = item.sortid; song.songid = (int)item.id; hypDB.PlaylistDatas.AddObject(song); hypDB.SaveChanges(); } //add new cloned chart (after playlist cloned) chartManager.AddNewChart(newClonedChart); } return(RedirectPermanent("/WebsiteManagement/manageCharts")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult AddNewFeaturedVideo(HttpPostedFileBase file, hypster_tv_DAL.videoFeaturedSlideshow p_featuredVideo) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { if (file != null && file.ContentLength > 0) { hypster_tv_DAL.videoFeatured featuredVideo = new hypster_tv_DAL.videoFeatured(); var extension = System.IO.Path.GetExtension(file.FileName); var path = System.IO.Path.Combine(Server.MapPath("~/uploads"), "new_featured_slide" + extension); file.SaveAs(path); string image_guid = System.Guid.NewGuid().ToString(); // // resize image // hypster_tv_DAL.Image_Resize_Manager image_resizer = new hypster_tv_DAL.Image_Resize_Manager(); image_resizer.Resize_Image(path, 621, 376, System.Drawing.Imaging.ImageFormat.Jpeg); System.IO.FileInfo file_slide = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_featured_slide" + extension); file_slide.CopyTo(System.Configuration.ConfigurationManager.AppSettings["videoSlideshowStorage_Path"] + "\\" + image_guid + file_slide.Extension, true); //delete file System.IO.FileInfo del_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_featured_slide" + extension); del_file.Delete(); hypster_tv_DAL.videoClipManager_Admin videoManager = new hypster_tv_DAL.videoClipManager_Admin(); int new_video_ID = videoManager.getVideoByGUID(p_featuredVideo.Guid).videoClip_ID; if (new_video_ID > 0) { featuredVideo.videoClip_ID = new_video_ID; featuredVideo.SortOrder = 0; featuredVideo.ImageSrc = image_guid + file_slide.Extension; hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hyDB.videoFeatureds.AddObject(featuredVideo); hyDB.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Please check image GUID. System can't find video."); } } else { ModelState.AddModelError("", "Please add image"); } return(View()); } else { return(RedirectPermanent("/home/")); } }
public ActionResult AddNewSlideshow(HttpPostedFileBase file, string href, bool isPopupMusicPlayer) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { if (file != null && file.ContentLength > 0) { hypster_tv_DAL.homeSlideshow homeSlide = new hypster_tv_DAL.homeSlideshow(); if (isPopupMusicPlayer == true) { homeSlide.href = "OpenPlayerM('" + href + "');"; } else { homeSlide.href = "window.location='" + href + "';"; } var extension = System.IO.Path.GetExtension(file.FileName); var path = System.IO.Path.Combine(Server.MapPath("~/uploads"), "new_home_slide" + extension); file.SaveAs(path); string image_guid = System.Guid.NewGuid().ToString(); // // resize image // System.IO.FileInfo file_slide = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_home_slide" + extension); file_slide.CopyTo(System.Configuration.ConfigurationManager.AppSettings["homeSlideshowStorage_Path"] + "\\" + image_guid + file_slide.Extension, true); //delete file System.IO.FileInfo del_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_home_slide" + extension); del_file.Delete(); hypster_tv_DAL.homeSlideshowManager slideshowManager = new hypster_tv_DAL.homeSlideshowManager(); slideshowManager.IncAllSlides(); homeSlide.isActive = true; homeSlide.SortOrder = 1; homeSlide.ImageSrc = image_guid + file_slide.Extension; hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hyDB.homeSlideshows.AddObject(homeSlide); hyDB.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Please add image"); } return(View()); } else { return(RedirectPermanent("/home/")); } }
public ActionResult Index(hypster_tv_DAL.videoClip clipToAdd, HttpPostedFileBase file) { string file_GUID = ""; if (file != null && file.ContentLength > 0) { if (clipToAdd.Name != null && clipToAdd.Name != "") { file_GUID = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 23); var fileName = System.IO.Path.GetFileName(file.FileName); var extension = System.IO.Path.GetExtension(file.FileName); var path = System.IO.Path.Combine(Server.MapPath("~/uploads_pending"), file_GUID + extension); file.SaveAs(path); clipToAdd.Guid = file_GUID; clipToAdd.UploadDate = DateTime.Now; clipToAdd.Duration = 0; clipToAdd.UploadedByName = User.Identity.Name; clipToAdd.Status = -1; //status (-1) - is pending need to be reviwed to have proper video format hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hyDB.AddTovideoClips(clipToAdd); hyDB.SaveChanges(); //return RedirectToAction("Index", "Home"); return(RedirectToAction("UploadConfirmation", "upload")); } else { ModelState.AddModelError("", "Please enter video name"); } } else { ModelState.AddModelError("", "Please select video"); } return(View()); }
public ActionResult EditSlideshow(HttpPostedFileBase file, int id, string ImgSrc, string href) { //string[] s = Request.AppRelativeCurrentExecutionFilePath.Split('/'); hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.homeSlideshowManager homeSlideshowManager = new hypster_tv_DAL.homeSlideshowManager(); hypster_tv_DAL.homeSlideshow slide = new hypster_tv_DAL.homeSlideshow(); //slide = homeSlideshowManager.homeSlideshowByID(Convert.ToInt32(s[s.Length - 1])); slide = homeSlideshowManager.homeSlideshowByID(id); string image_guid = ""; if (file != null && file.ContentLength > 0) { var extension = System.IO.Path.GetExtension(file.FileName); var path = System.IO.Path.Combine(Server.MapPath("~/uploads"), "new_home_slide" + extension); file.SaveAs(path); image_guid = System.Guid.NewGuid().ToString(); // // resize image // hypster_tv_DAL.Image_Resize_Manager image_resizer = new hypster_tv_DAL.Image_Resize_Manager(); image_resizer.Resize_Image(path, 621, 376, System.Drawing.Imaging.ImageFormat.Jpeg); System.IO.FileInfo file_slide = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_home_slide" + extension); file_slide.CopyTo(System.Configuration.ConfigurationManager.AppSettings["homeSlideshowStorage_Path"] + "\\" + image_guid + extension, true); //delete file System.IO.FileInfo del_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_home_slide" + extension); del_file.Delete(); slide.ImageSrc = image_guid + extension; } else { slide.ImageSrc = ImgSrc; } slide.href = href; hyDB.sp_homeSlideshow_UpdateHomeSlideshow(slide.homeSlideshow_ID, slide.href, slide.ImageSrc); hyDB.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult SaveHypsterChart(List <int> playlist_songs_list, string conv_PlaylistName, int conv_UserID) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.Playlist add_playlist = new hypster_tv_DAL.Playlist(); add_playlist.name = conv_PlaylistName; add_playlist.userid = conv_UserID; string crtd = DateTime.Now.ToString("yyyyMMdd"); int crtd_i = 0; Int32.TryParse(crtd, out crtd_i); add_playlist.create_time = crtd_i; int new_plst_id = playlistManager.AddNewPlaylist(add_playlist); short Sel_Sort_Order = 1; if (playlist_songs_list != null) { foreach (int item_id in playlist_songs_list) { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = new_plst_id; new_playlistData.songid = item_id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = conv_UserID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); Sel_Sort_Order++; } } return(RedirectPermanent("/WebsiteManagement/manageCharts")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult PostSongComment(string songComment, string songGuid) { if (User.Identity.IsAuthenticated == false) { return(RedirectPermanent("/account/SignIn?ReturnUrl=/song/" + songGuid)); } hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.songsManagement songManager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.Song curr_song = new hypster_tv_DAL.Song(); curr_song = songManager.GetSongByID(songGuid); hypster_tv_DAL.songComment p_comment = new hypster_tv_DAL.songComment(); p_comment.song_ID = curr_song.id; p_comment.ipAddress = IpAddress(); p_comment.status = (int)hypster_tv_DAL.newsCommentStatus.NoActive; p_comment.user_ID = memberManager.getMemberByUserName(User.Identity.Name).id; p_comment.userName = User.Identity.Name; p_comment.postDate = DateTime.Now; p_comment.comment = songComment; if (p_comment.comment.Length > 1990) { p_comment.comment = p_comment.comment.Substring(0, 1990); } hyDB.songComments.AddObject(p_comment); hyDB.SaveChanges(); return(RedirectPermanent("/song/" + songGuid)); }
public ActionResult AddNewPlaylist(string AddPlaylist_Name) { hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); if (AddPlaylist_Name != "") { hypster_tv_DAL.Member member = new hypster_tv_DAL.Member(); member = memberManager.getMemberByUserName(User.Identity.Name); hypster_tv_DAL.Playlist playlist = new hypster_tv_DAL.Playlist(); playlist.name = AddPlaylist_Name; playlist.userid = member.id; string crtd = DateTime.Now.ToString("yyyyMMdd"); int crtd_i = 0; Int32.TryParse(crtd, out crtd_i); playlist.create_time = crtd_i; if (playlist.name.Length > 60) { playlist.name = playlist.name.Substring(0, 60); } hypster_tv_DAL.Hypster_Entities hyDB_man = new hypster_tv_DAL.Hypster_Entities(); hyDB_man.Playlists.AddObject(playlist); hyDB_man.SaveChanges(); hypster_tv_DAL.playlistManagement playlistManagement = new hypster_tv_DAL.playlistManagement(); List <hypster_tv_DAL.Playlist> playlists_list = playlistManagement.GetUserPlaylists(member.id); if (member.active_playlist == 0 && playlists_list.Count > 0) { member.active_playlist = playlists_list[0].id; memberManager.SetUserDefaultPlaylist(User.Identity.Name, member.id, member.active_playlist); } } return(RedirectPermanent("/Editors/managePlaylist/")); }
public ActionResult AddNewSlideshow(HttpPostedFileBase file, string href) { if (file != null && file.ContentLength > 0) { hypster_tv_DAL.homeSlideshow homeSlide = new hypster_tv_DAL.homeSlideshow(); var extension = System.IO.Path.GetExtension(file.FileName); var path = System.IO.Path.Combine(Server.MapPath("~/uploads"), "new_home_slide" + extension); file.SaveAs(path); string image_guid = System.Guid.NewGuid().ToString(); System.IO.FileInfo file_slide = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_home_slide" + extension); file_slide.CopyTo(System.Configuration.ConfigurationManager.AppSettings["homeSlideshowStorage_Path"] + "\\" + image_guid + file_slide.Extension, true); //delete file System.IO.FileInfo del_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_home_slide" + extension); del_file.Delete(); hypster_tv_DAL.homeSlideshowManager slideshowManager = new hypster_tv_DAL.homeSlideshowManager(); slideshowManager.IncAllSlides(); homeSlide.href = href; homeSlide.isActive = false; homeSlide.SortOrder = 1; homeSlide.ImageSrc = image_guid + file_slide.Extension; hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hyDB.homeSlideshows.AddObject(homeSlide); hyDB.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Please add image"); } return(View()); }
public ActionResult AddNewPost(hypster_tv_DAL.newsPost p_newPost) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.newsManagement_Admin newsManager = new hypster_tv_DAL.newsManagement_Admin(); if (p_newPost.post_title != null && p_newPost.post_title != "") { p_newPost.post_date = DateTime.Now; p_newPost.post_guid = p_newPost.post_title.Replace("/", "").Replace("\\", "").Replace("&", "").Replace("+", "").Replace(" ", "-").Replace("?", "").Replace("!", "").Replace("*", "").Replace("$", "").Replace("\"", "").Replace("'", "").Replace("{", "").Replace("}", "").Replace(")", "").Replace("(", "").Replace("[", "").Replace("]", "").Replace("|", "").Replace(".", "").Replace(",", "").Replace(":", "").Replace(";", ""); p_newPost.post_status = (int)hypster_tv_DAL.postStatus.NoActive; // //check if post guid is exist in database hypster_tv_DAL.newsPost post_check = newsManager.GetPostByGUID(p_newPost.post_guid); if (post_check.post_id != 0 && post_check.post_guid != "") { ModelState.AddModelError("", "NOT ABLE TO GENERATE POST GUID.Please choose modify title. Post with following title already exist."); } else //if post guid is unique then procceed to finish { hyDB.newsPosts.AddObject(p_newPost); hyDB.SaveChanges(); return(RedirectToAction("Index", "homeNews")); } } else { ModelState.AddModelError("", "Please enter post title. It must be unique from previous posts!!!"); } // if no success return(View(new hypster_tv_DAL.newsPost())); } else { return(RedirectPermanent("/home/")); } }
public ActionResult ConvertYearToPlaylist(string plst_name, int?curr_year, int?user_id) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { List <hypster_tv_DAL.PlaylistData_Song> new_songs = new List <hypster_tv_DAL.PlaylistData_Song>(); short CURR_SORT_ID = 1; int CURR_USER_ID = (int)user_id; //------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------- hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.Playlist new_playlist = new hypster_tv_DAL.Playlist(); new_playlist.create_time = 0; new_playlist.is_artist_playlist = false; new_playlist.name = plst_name; new_playlist.update_time = 0; new_playlist.userid = (int)user_id; new_playlist.ViewsNum = 0; new_playlist.Likes = 0; int NEW_PLAYLIST_ID = playlistManager.AddNewPlaylist(new_playlist); //------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------- string currURL = "http://en.wikipedia.org/wiki/Billboard_Year-End_Hot_100_singles_of_" + curr_year.ToString(); var strContent = ""; var webRequest = WebRequest.Create(currURL); using (var response = webRequest.GetResponse()) using (var content = response.GetResponseStream()) using (var reader = new StreamReader(content)) { strContent = reader.ReadToEnd(); } //------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------- HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(strContent); ViewBag.Chart_Header = "Billboard Year-End Hot 100 singles of " + curr_year; ViewBag.curr_year = curr_year; //------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------------- if (curr_year >= 1982) { HtmlAgilityPack.HtmlNode songNode = doc.DocumentNode.SelectSingleNode("/html/body/div/div/div/table"); if (songNode != null) { HtmlAgilityPack.HtmlNodeCollection nodes_list = doc.DocumentNode.SelectNodes("/html/body/div/div/div/table/tr/td"); if (nodes_list != null) { int i_counter = 1; for (var i = 0; i < nodes_list.Count; i += 2) { if ((i + 1) < nodes_list.Count) { // get curr song guid //----------------------------------------------------------------------------------------- string artist_song = ""; artist_song = nodes_list[i].InnerText + " - " + nodes_list[i + 1].InnerText; Video CURR_VIDEO = new Video(); CURR_VIDEO = GetSongVideoByTitle(artist_song); //----------------------------------------------------------------------------------------- //get song by guid //----------------------------------------------------------------------------------------- hypster_tv_DAL.Song song = new hypster_tv_DAL.Song(); song = songsManager.GetSongByGUID(CURR_VIDEO.VideoId); //----------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------- if (song.id == 0) //add new song { if (CURR_VIDEO.Title != null && CURR_VIDEO.VideoId != null) { //need to modify to add more song params hypster_tv_DAL.Song new_song = new hypster_tv_DAL.Song(); new_song.Title = CURR_VIDEO.Title; new_song.YoutubeId = CURR_VIDEO.VideoId; new_song.adddate = DateTime.Now; new_song.YoutubeProcessed = false; if (CURR_VIDEO.Author != null) { new_song.Author = CURR_VIDEO.Uploader; } //if (CURR_VIDEO.RatingAverage != null) if (CURR_VIDEO.RatingAverage != 0) { new_song.Rating = (float)CURR_VIDEO.RatingAverage; } if (CURR_VIDEO.AppControl != null) { new_song.Syndication = 1; } hypDB.Songs.AddObject(new_song); hypDB.SaveChanges(); //get newely added song song = songsManager.GetSongByGUID(CURR_VIDEO.VideoId); //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = NEW_PLAYLIST_ID; new_playlistData.songid = song.id; new_playlistData.sortid = CURR_SORT_ID; new_playlistData.userid = CURR_USER_ID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } } else //if song exist in database { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = NEW_PLAYLIST_ID; new_playlistData.songid = song.id; new_playlistData.sortid = CURR_SORT_ID; new_playlistData.userid = CURR_USER_ID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } //----------------------------------------------------------------------------------------- i_counter += 1; CURR_SORT_ID += 1; } } } } } else { HtmlAgilityPack.HtmlNode songNode = doc.DocumentNode.SelectSingleNode("/html/body/div/div/div/table"); if (songNode != null) { HtmlAgilityPack.HtmlNodeCollection nodes_list = doc.DocumentNode.SelectNodes("/html/body/div/div/div/table/tr/td"); if (nodes_list != null) { int i_counter = 1; for (var i = 0; i < nodes_list.Count; i += 3) { if ((i + 2) < nodes_list.Count) { // get curr song guid //----------------------------------------------------------------------------------------- string artist_song = ""; artist_song = nodes_list[i + 1].InnerText + " - " + nodes_list[i + 2].InnerText; Video CURR_VIDEO = new Video(); CURR_VIDEO = GetSongVideoByTitle(artist_song); //----------------------------------------------------------------------------------------- //get song by guid //----------------------------------------------------------------------------------------- hypster_tv_DAL.Song song = new hypster_tv_DAL.Song(); song = songsManager.GetSongByGUID(CURR_VIDEO.VideoId); //----------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------- if (song.id == 0) //add new song { //need to modify to add more song params hypster_tv_DAL.Song new_song = new hypster_tv_DAL.Song(); new_song.Title = CURR_VIDEO.Title; new_song.YoutubeId = CURR_VIDEO.VideoId; new_song.adddate = DateTime.Now; new_song.YoutubeProcessed = false; if (CURR_VIDEO.Author != null) { new_song.Author = CURR_VIDEO.Uploader; } if (CURR_VIDEO.RatingAverage != 0) { new_song.Rating = (float)CURR_VIDEO.RatingAverage; } if (CURR_VIDEO.AppControl != null) { new_song.Syndication = 1; } hypDB.Songs.AddObject(new_song); hypDB.SaveChanges(); //get newely added song song = songsManager.GetSongByGUID(CURR_VIDEO.VideoId); //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = NEW_PLAYLIST_ID; new_playlistData.songid = song.id; new_playlistData.sortid = CURR_SORT_ID; new_playlistData.userid = CURR_USER_ID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } else //if song exist in database { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = NEW_PLAYLIST_ID; new_playlistData.songid = song.id; new_playlistData.sortid = CURR_SORT_ID; new_playlistData.userid = CURR_USER_ID; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } //----------------------------------------------------------------------------------------- i_counter += 1; CURR_SORT_ID += 1; } } } } } //------------------------------------------------------------------------------------------------------------------------------- return(RedirectPermanent("/WebsiteManagement/manageCharts")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult SubmitAddNewSongPopup(string Song_Title, string Song_Guid, int?Sel_Playlist_ID, int?StayHereCheck) { // 1.genral declarations //-------------------------------------------------------------------------------------------- hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.memberManagement userManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.playlistManagement playlistManagement = new hypster_tv_DAL.playlistManagement(); //-------------------------------------------------------------------------------------------- //get curr user //----------------------------------------------------------------------------------------- hypster_tv_DAL.Member curr_user = new hypster_tv_DAL.Member(); curr_user = userManager.getMemberByUserName(User.Identity.Name); //----------------------------------------------------------------------------------------- //check if user has default playlist //----------------------------------------------------------------------------------------- if (curr_user.active_playlist == 0) { hypster_tv_DAL.Playlist create_playlist = new hypster_tv_DAL.Playlist(); create_playlist.name = curr_user.username + "'s playlist"; create_playlist.userid = curr_user.id; if (create_playlist.name.Length > 60) { create_playlist.name = create_playlist.name.Substring(0, 60); } hypDB.Playlists.AddObject(create_playlist); hypDB.SaveChanges(); List <hypster_tv_DAL.Playlist> playlists_list = playlistManagement.GetUserPlaylists(curr_user.id); if (playlists_list.Count > 0) { curr_user.active_playlist = playlists_list[0].id; userManager.SetUserDefaultPlaylist(User.Identity.Name, curr_user.id, curr_user.active_playlist); } //else error - need to have dafult playlist } //----------------------------------------------------------------------------------------- //check if user selected playlist //----------------------------------------------------------------------------------------- if (Sel_Playlist_ID == null || Sel_Playlist_ID == 0) { Sel_Playlist_ID = curr_user.active_playlist; } //----------------------------------------------------------------------------------------- // get last sort_number //----------------------------------------------------------------------------------------- short Sel_Sort_Order = 0; //List<hypster_tv_DAL.PlaylistData_Song> songs_list = new List<hypster_tv_DAL.PlaylistData_Song>(); //songs_list = playlistManagement.GetSongsForPlayList(curr_user.id, (int)Sel_Playlist_ID); //if (songs_list.Count > 0) //{ // Sel_Sort_Order = songs_list[0].sortid; // for (int i = 0; i < songs_list.Count; i++) // { // if (songs_list[i].sortid > Sel_Sort_Order) // Sel_Sort_Order = songs_list[i].sortid; // } //} //Sel_Sort_Order += 1; playlistManagement.IncrementPlaylistSongOrder(curr_user.id, (int)Sel_Playlist_ID); //set sort order to first position Sel_Sort_Order = 1; //----------------------------------------------------------------------------------------- //get song by guid //----------------------------------------------------------------------------------------- hypster_tv_DAL.Song song = new hypster_tv_DAL.Song(); song = songsManager.GetSongByGUID(Song_Guid); //----------------------------------------------------------------------------------------- if (Song_Title.Length > 160) { Song_Title = Song_Title.Substring(0, 160); } //----------------------------------------------------------------------------------------- if (song.id == 0) //add new song { string video_Author = ""; float video_RatingAverage = 0; byte video_AppControl = 0; string video_Title = ""; try { //need to get song details YouTubeRequestSettings settings = new YouTubeRequestSettings("hypster", "AI39si5TNjKgF6yiHwUhKbKwIui2JRphXG4hPXUBdlrNh4XMZLXu--lf66gVSPvks9PlWonEk2Qv9fwiadpNbiuh-9TifCNsqA"); YouTubeRequest request = new YouTubeRequest(settings); string feedUrl = "http://gdata.youtube.com/feeds/api/videos/" + Song_Guid; Video video = request.Retrieve <Video>(new Uri(feedUrl)); if (video.Author != null) { video_Author = video.Uploader; } if (video.RatingAverage != null) { video_RatingAverage = (float)video.RatingAverage; } if (video.AppControl != null) { video_AppControl = 1; } if (video.Title != null) { video_Title = video.Title; } } catch (Exception ex) { } //need to modify to add more song params hypster_tv_DAL.Song new_song = new hypster_tv_DAL.Song(); new_song.Title = video_Title; new_song.YoutubeId = Song_Guid; new_song.adddate = DateTime.Now; new_song.YoutubeProcessed = false; new_song.Author = video_Author; new_song.Rating = video_RatingAverage; new_song.Syndication = video_AppControl; hypDB.Songs.AddObject(new_song); hypDB.SaveChanges(); //get newely added song song = songsManager.GetSongByGUID(Song_Guid); //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = Sel_Playlist_ID; new_playlistData.songid = song.id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = userManager.getMemberByUserName(User.Identity.Name).id; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } else //if song exist in database { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = Sel_Playlist_ID; new_playlistData.songid = song.id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = curr_user.id; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } //----------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------- return(Content("SUCCESS", "text/html")); //----------------------------------------------------------------------------------------- }
public ActionResult clonePlaylist() { hypster_admin.Areas.Editors.ViewModels.PlaylistViewModel model = new hypster_admin.Areas.Editors.ViewModels.PlaylistViewModel(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.playlistManagement playlistManager = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.TagManagement tagManager = new hypster_tv_DAL.TagManagement(); string playlistId = Request.QueryString["playlistId"]; string playlistName = ""; if (playlistId != "") { hypster_tv_DAL.Member member = new hypster_tv_DAL.Member(); if (Request.QueryString["cloneTo"] != "") { member = memberManager.getMemberByUserName(Request.QueryString["cloneTo"]); } else { member = memberManager.getMemberByUserName(User.Identity.Name); } if (Request.QueryString["playlistName"] != "") { playlistName = Request.QueryString["playlistName"]; hypster_tv_DAL.Playlist playlist = new hypster_tv_DAL.Playlist(); playlist.name = playlistName; playlist.userid = member.id; string crtd = DateTime.Now.ToString("yyyyMMdd"); int crtd_i = 0; Int32.TryParse(crtd, out crtd_i); playlist.create_time = crtd_i; if (playlist.name.Length > 60) { playlist.name = playlist.name.Substring(0, 60); } hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hyDB.Playlists.AddObject(playlist); hyDB.SaveChanges(); List <hypster_tv_DAL.Playlist> playlists_list = playlistManager.GetUserPlaylists(member.id); int clLsId = playlists_list[playlists_list.Count - 1].id; int plId = Convert.ToInt32(playlistId); model.playlistData_Song = playlistManager.GetPlayListDataByPlaylistID(plId); model.tags_list = tagManager.GetPlaylistTags(plId); for (int i = 0; i < model.playlistData_Song.Count; i++) { if (model.playlistData_Song[i].id != null) { hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = clLsId; new_playlistData.songid = (int)model.playlistData_Song[i].id; new_playlistData.sortid = model.playlistData_Song[i].sortid; new_playlistData.userid = member.id; hyDB.PlaylistDatas.AddObject(new_playlistData); hyDB.SaveChanges(); } } for (int j = 0; j < model.tags_list.Count; j++) { if (model.tags_list[j].Tag_ID != null) { hypster_tv_DAL.Tag_Playlist plTag = new hypster_tv_DAL.Tag_Playlist(); plTag.Playlist_ID = clLsId; plTag.Tag_ID = model.tags_list[j].Tag_ID; hyDB.Tag_Playlist.AddObject(plTag); hyDB.SaveChanges(); } } } else { Exception PlaylistNameNull = new Exception("The Playlist Name is NULL.\n\n"); Response.Write("Error: " + PlaylistNameNull.Message); } } else { Exception PlaylistIdNull = new Exception("The Playlist ID " + playlistId + " is NULL.\n\n"); Response.Write("Error: " + PlaylistIdNull.Message); } return(RedirectPermanent("/Editors/managePlaylist/")); }
public string SubmitAddNewSong(string Song_Title, string Song_Guid, string Sel_Playlist_ID) { hypster_tv_DAL.Hypster_Entities hypDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.songsManagement songsManager = new hypster_tv_DAL.songsManagement(); hypster_tv_DAL.memberManagement userManager = new hypster_tv_DAL.memberManagement(); hypster_tv_DAL.playlistManagement playlistManagement = new hypster_tv_DAL.playlistManagement(); hypster_tv_DAL.Member curr_user = new hypster_tv_DAL.Member(); curr_user = userManager.getMemberByUserName(User.Identity.Name); if (curr_user.active_playlist == 0) { hypster_tv_DAL.Playlist create_playlist = new hypster_tv_DAL.Playlist(); create_playlist.name = curr_user.username + "'s playlist"; create_playlist.userid = curr_user.id; string crtd = DateTime.Now.ToString("yyyyMMdd"); int crtd_i = 0; Int32.TryParse(crtd, out crtd_i); create_playlist.create_time = crtd_i; if (create_playlist.name.Length > 60) { create_playlist.name = create_playlist.name.Substring(0, 60); } hypDB.Playlists.AddObject(create_playlist); hypDB.SaveChanges(); List <hypster_tv_DAL.Playlist> playlists_list = playlistManagement.GetUserPlaylists(curr_user.id); if (playlists_list.Count > 0) { curr_user.active_playlist = playlists_list[0].id; userManager.SetUserDefaultPlaylist(User.Identity.Name, curr_user.id, curr_user.active_playlist); } //else error - need to have dafult playlist } //----------------------------------------------------------------------------------------- //check if user selected playlist //----------------------------------------------------------------------------------------- if (Sel_Playlist_ID == null) { Sel_Playlist_ID = curr_user.active_playlist.ToString(); } //----------------------------------------------------------------------------------------- // get last sort_number //----------------------------------------------------------------------------------------- short Sel_Sort_Order = 0; playlistManagement.IncrementPlaylistSongOrder(curr_user.id, Convert.ToInt32(Sel_Playlist_ID)); //set sort order to first position Sel_Sort_Order = 1; //----------------------------------------------------------------------------------------- //get song by guid //----------------------------------------------------------------------------------------- hypster_tv_DAL.Song song = new hypster_tv_DAL.Song(); song = songsManager.GetSongByGUID(Song_Guid); //----------------------------------------------------------------------------------------- if (Song_Title.Length > 75) { Song_Title = Song_Title.Substring(0, 75); } //----------------------------------------------------------------------------------------- if (song.id == 0) //add new song { var youtubeService = new YouTubeService(new BaseClientService.Initializer() { ApiKey = System.Configuration.ConfigurationManager.AppSettings["YouTubeAPIKEY"], ApplicationName = System.Configuration.ConfigurationManager.AppSettings["YouTubeAPIKEYName"] }); var searchListRequest = youtubeService.Search.List("id,snippet"); searchListRequest.Q = Song_Guid; // Replace with your search term. searchListRequest.MaxResults = 1; var searchListResponse = searchListRequest.Execute(); SearchResult video = new SearchResult(); foreach (var searchResult in searchListResponse.Items) { switch (searchResult.Id.Kind) { case "youtube#video": video = searchResult; break; } } //need to modify to add more song params hypster_tv_DAL.Song new_song = new hypster_tv_DAL.Song(); new_song.Title = Song_Title; new_song.YoutubeId = Song_Guid; new_song.adddate = DateTime.Now; new_song.YoutubeProcessed = false; new_song.Author = ""; new_song.Rating = 1; new_song.Syndication = 1; hypDB.Songs.AddObject(new_song); hypDB.SaveChanges(); //get newely added song song = songsManager.GetSongByGUID(Song_Guid); //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = Convert.ToInt32(Sel_Playlist_ID); new_playlistData.songid = song.id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = userManager.getMemberByUserName(User.Identity.Name).id; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } else //if song exist in database { //add to playlist data hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData(); new_playlistData.playlist_id = Convert.ToInt32(Sel_Playlist_ID); new_playlistData.songid = song.id; new_playlistData.sortid = Sel_Sort_Order; new_playlistData.userid = curr_user.id; hypDB.PlaylistDatas.AddObject(new_playlistData); hypDB.SaveChanges(); } return("A New Song, " + Song_Title + " (ID: " + Song_Guid + ") has been added to the Playlist, " + playlistManagement.GetPlaylistById(Convert.ToInt32(Sel_Playlist_ID))[0].name); //return RedirectPermanent("/Editors/managePlaylist/?playlist_id=" + Sel_Playlist_ID); }
//log exception protected override void OnException(ExceptionContext filterContext) { hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); //----------------------------------------------------------------------------- //collect exc data string action = filterContext.RouteData.Values["action"].ToString(); string controller = filterContext.RouteData.Values["controller"].ToString(); string message = ""; if (filterContext.Exception.Message != null) { message += filterContext.Exception.Message.ToString(); } if (filterContext.Exception.InnerException != null) { message += " | " + filterContext.Exception.InnerException.ToString(); } string url_string = filterContext.HttpContext.Request.RawUrl; string IP_Address; IP_Address = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (IP_Address == null) { IP_Address = Request.ServerVariables["REMOTE_ADDR"]; } else { IP_Address = ""; } //----------------------------------------------------------------------------- string member_str = ""; if (User.Identity.IsAuthenticated) { member_str = User.Identity.Name; } //----------------------------------------------------------------------------- // save exc data hypster_tv_DAL.HypException i_exception = new hypster_tv_DAL.HypException(); i_exception.ExcDate = DateTime.Now; i_exception.ExcIP = IP_Address; i_exception.ExcUrl = url_string; i_exception.ExcMethod = controller + ":" + action + ":" + member_str; i_exception.ExcMessage = message; if (i_exception.ExcUrl.Length > 145) { i_exception.ExcUrl = i_exception.ExcUrl.Substring(0, 145); } if (i_exception.ExcMethod.Length > 145) { i_exception.ExcMethod = i_exception.ExcMethod.Substring(0, 145); } if (i_exception.ExcMessage.Length > 345) { i_exception.ExcMessage = i_exception.ExcMessage.Substring(0, 345); } hyDB.HypExceptions.AddObject(i_exception); hyDB.SaveChanges(); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- filterContext.ExceptionHandled = true; }
public ActionResult AddNewUser(hypster_tv_DAL.Member member, int DOB_YYYY, int DOB_MM, int DOB_DD) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.Member memberAdd = new hypster_tv_DAL.Member(); hypster_tv_DAL.Hypster_Entities hyDB = new hypster_tv_DAL.Hypster_Entities(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); memberAdd.username = member.username; memberAdd.password = member.password; memberAdd.name = member.name; memberAdd.email = member.email; memberAdd.adminLevel = member.adminLevel; memberAdd.country = member.country; memberAdd.city = member.city; memberAdd.zipcode = member.zipcode; memberAdd.birth = new DateTime(DOB_YYYY, DOB_MM, DOB_DD); memberAdd.sex = Convert.ToByte(member.sex); string IP_Address; IP_Address = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (IP_Address == null) { IP_Address = Request.ServerVariables["REMOTE_ADDR"]; } else { IP_Address = ""; } memberAdd.RegistrationIp = IP_Address; memberAdd.regdate = DateTime.Now; if (memberAdd.username != "" && memberAdd.password != "" && memberAdd.name != "" && memberAdd.email != "") { bool usernameClean = (memberManager.getMemberByUserName(memberAdd.username).id == 0); bool emailClean = (memberManager.getMemberByEmail(memberAdd.email).id == 0); if (!usernameClean) { ModelState.AddModelError("", "The Username has already been used, please select another one!!"); return(View(memberAdd)); } if (!emailClean) { ModelState.AddModelError("", "The Email Address has already been registered, please choose another email address!!"); return(View(memberAdd)); } hyDB.Members.AddObject(memberAdd); hyDB.SaveChanges(); return(RedirectToAction("Index", "manageUsers")); } else { ModelState.AddModelError("", "Please Fill Up the Username, Password, Name, and Email for the New User!!"); return(View(memberAdd)); } } else { return(RedirectPermanent("/home/")); } }