public ActionResult Edit(HttpPostedFileBase file, hypster_tv_DAL.videoFeaturedSlideshow featuredVideo) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { if (file != null && file.ContentLength > 0) { 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 = featuredVideo.ImageSrc; // // 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, true); //delete file System.IO.FileInfo del_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_featured_slide" + extension); del_file.Delete(); } return(RedirectToAction("Index")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult AddManualImage(int Img_Manual_ID, int Manual_Active, HttpPostedFileBase Img_Manual_Image) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.manualManagement manualManager = new hypster_tv_DAL.manualManagement(); hypster_tv_DAL.Manual currManual = new hypster_tv_DAL.Manual(); currManual = manualManager.GetManualByID(Img_Manual_ID); currManual.Manual_Active = Manual_Active; manualManager.UpdateManual(currManual); if (Img_Manual_Image != null && Img_Manual_Image.FileName != null && Img_Manual_Image.FileName != "") { System.IO.DirectoryInfo dirInf = new System.IO.DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["ManualsStorage_Path"] + "\\" + currManual.Manual_Guid); if (dirInf.Exists == false) { dirInf.Create(); } var extension = ".jpg"; //System.IO.Path.GetExtension(Img_Manual_Image.FileName); string tmp_image_path = System.Configuration.ConfigurationManager.AppSettings["ManualsStorage_Path"] + "\\" + currManual.Manual_Guid + "\\TMP_" + Img_Manual_ID + extension; string perm_image_path = System.Configuration.ConfigurationManager.AppSettings["ManualsStorage_Path"] + "\\" + currManual.Manual_Guid + "\\" + Img_Manual_ID + extension; Img_Manual_Image.SaveAs(tmp_image_path); hypster_tv_DAL.Image_Resize_Manager imageResizer = new hypster_tv_DAL.Image_Resize_Manager(); imageResizer.Resize_Image(tmp_image_path, 700, -1, System.Drawing.Imaging.ImageFormat.Jpeg, perm_image_path, 70L); System.IO.FileInfo file_del = new System.IO.FileInfo(tmp_image_path); file_del.Delete(); } return(RedirectPermanent("/WebsiteManagement/manageManuals")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult AddToFeatured(string href, string href_mobile, string name, string image, int plstType, int ContID, string ContType) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.homeSlideshowManager slideshowManager = new hypster_tv_DAL.homeSlideshowManager(); hypster_tv_DAL.homeSlideshow slideshow = new hypster_tv_DAL.homeSlideshow(); slideshow = slideshowManager.homeSlideshowByID(ContID); hypster_tv_DAL.Image_Resize_Manager image_resizer = new hypster_tv_DAL.Image_Resize_Manager(); image_resizer.Resize_Image(System.Configuration.ConfigurationManager.AppSettings["homeSlideshowStorage_Path"] + "\\" + image, 800, -1, System.Drawing.Imaging.ImageFormat.Jpeg, System.Configuration.ConfigurationManager.AppSettings["homeSlideshowStorage_Path"] + "\\" + "sm_" + image); hypster_tv_DAL.featuredContentManagement fc_manager = new hypster_tv_DAL.featuredContentManagement(); hypster_tv_DAL.FeaturedContent fc_add = new hypster_tv_DAL.FeaturedContent(); fc_add.fc_active = true; fc_add.fc_href = href; fc_add.fc_href_mobile = href_mobile; fc_add.fc_name = name; fc_add.fc_image = "sm_" + image; // need to resize fc_add.fc_type = plstType; fc_manager.hyDB.FeaturedContents.AddObject(fc_add); fc_manager.hyDB.SaveChanges(); return(RedirectPermanent("/WebsiteManagement/manageFeatured")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult AddNewArtist(HttpPostedFileBase file, string name, int genre_id) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.visualSearchManager visualSearchManager = new hypster_tv_DAL.visualSearchManager(); if (visualSearchManager.getVisualSearchArtistByName(name).VisualSearch_ID == 0) //if not exist yet - then add new artist { string savePath = System.Configuration.ConfigurationManager.AppSettings["visualSearchStorage_Path"] + "\\" + name + ".jpg"; file.SaveAs(savePath); hypster_tv_DAL.Image_Resize_Manager image_resizer = new hypster_tv_DAL.Image_Resize_Manager(); image_resizer.Resize_Image(savePath, -1, 120, System.Drawing.Imaging.ImageFormat.Jpeg); int ImWidth = 0; System.Drawing.Image img = System.Drawing.Image.FromFile(savePath); ImWidth = img.Width; hypster_tv_DAL.VisualSearch visSearch = new hypster_tv_DAL.VisualSearch(); visSearch.Artist_Name = name; visSearch.Genre_ID = genre_id; visSearch.ImWidth = ImWidth; visualSearchManager.addVisualSearch(visSearch); return(RedirectPermanent("/WebsiteManagement/hypArtists")); } hypster_admin.Areas.WebsiteManagement.ViewModels.hypArtistsViewModel model = new ViewModels.hypArtistsViewModel(); ViewBag.Value = "Already Exist"; return(View("Index", model)); } 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 UploadPostImageEdit(HttpPostedFileBase file, int post_id) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { if (file != null && file.ContentLength > 0) { hypster_tv_DAL.newsManagement_Admin newsManager = new hypster_tv_DAL.newsManagement_Admin(); hypster_tv_DAL.Image_Resize_Manager image_resizer = new hypster_tv_DAL.Image_Resize_Manager(); hypster_tv_DAL.newsPost p_Post = new hypster_tv_DAL.newsPost(); p_Post = newsManager.GetPostByID(post_id); var extension = System.IO.Path.GetExtension(file.FileName); var path = System.IO.Path.Combine(Server.MapPath("~/uploads"), "new_post" + extension); file.SaveAs(path); //save post image System.IO.FileInfo fileInf = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_post" + extension); fileInf.CopyTo(System.Configuration.ConfigurationManager.AppSettings["newsImageStorage_Path"] + "\\" + p_Post.post_guid + fileInf.Extension, true); // // resize image old int video_width = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["postImage_maxWidth"]); image_resizer.Resize_Image(System.Configuration.ConfigurationManager.AppSettings["newsImageStorage_Path"] + "\\" + p_Post.post_guid + fileInf.Extension, video_width, -1, System.Drawing.Imaging.ImageFormat.Jpeg); //save thumbnail System.IO.FileInfo thumb_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_post" + extension); string new_thumb_path = System.Configuration.ConfigurationManager.AppSettings["newsImageStorage_Path"] + "\\thumb_" + p_Post.post_guid + thumb_file.Extension; thumb_file.CopyTo(new_thumb_path, true); int thumb_width = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["postThumb_maxWidth"]); image_resizer.Resize_Image(new_thumb_path, thumb_width, -1, System.Drawing.Imaging.ImageFormat.Jpeg); //save new image System.IO.FileInfo newim_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_post" + extension); string newim_path = System.Configuration.ConfigurationManager.AppSettings["newsImageStorage_Path"] + "\\img_" + p_Post.post_guid + newim_file.Extension; newim_file.CopyTo(newim_path, true); int newim_width = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["newPostImage_maxWidth"]); image_resizer.Resize_Image(newim_path, newim_width, -1, System.Drawing.Imaging.ImageFormat.Jpeg); //delete file System.IO.FileInfo del_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_post" + extension); del_file.Delete(); p_Post.post_image = p_Post.post_guid + fileInf.Extension; // // save post after image is done newsManager.EditPost(p_Post); } return(RedirectToAction("Edit", new { id = post_id })); } else { return(RedirectPermanent("/home/")); } }
public ActionResult AddNewCeleb(HttpPostedFileBase file, string txt_Name, string txt_Url) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { if (file != null && file.ContentLength > 0) { hypster_tv_DAL.celebsManagement celebsManager = new hypster_tv_DAL.celebsManagement(); hypster_tv_DAL.Image_Resize_Manager image_resizer = new hypster_tv_DAL.Image_Resize_Manager(); hypster_tv_DAL.newsCeleb p_celeb = new hypster_tv_DAL.newsCeleb(); p_celeb.celeb_name = txt_Name; p_celeb.celeb_url = txt_Url; p_celeb.celeb_image = txt_Name.Replace("/", "").Replace("\\", "").Replace("&", "").Replace("+", "").Replace(" ", "-").Replace("?", "").Replace("!", "").Replace("*", "").Replace("$", "").Replace("\"", "").Replace("'", "").Replace("{", "").Replace("}", "").Replace(")", "").Replace("(", "").Replace("[", "").Replace("]", "").Replace("|", "").Replace(".", "").Replace(",", "").Replace(":", "").Replace(";", ""); p_celeb.celeb_image = p_celeb.celeb_image + "_" + DateTime.Now.ToShortDateString().Replace("/", "_"); var extension = System.IO.Path.GetExtension(file.FileName); var path = System.IO.Path.Combine(Server.MapPath("~/uploads"), "new_post" + extension); file.SaveAs(path); // // resize image int video_width = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["postCelebImage_maxWidth"]); image_resizer.Resize_Image(path, video_width, -1, System.Drawing.Imaging.ImageFormat.Jpeg); //save post image System.IO.FileInfo fileInf = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_post" + extension); fileInf.CopyTo(System.Configuration.ConfigurationManager.AppSettings["newsCelebsImageStorage_Path"] + "\\" + p_celeb.celeb_image + fileInf.Extension, true); //save thumbnail System.IO.FileInfo thumb_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_post" + extension); string new_thumb_path = System.Configuration.ConfigurationManager.AppSettings["newsCelebsImageStorage_Path"] + "\\thumb_" + p_celeb.celeb_image + thumb_file.Extension; thumb_file.CopyTo(new_thumb_path, true); int thumb_width = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["postCelebThumb_maxWidth"]); image_resizer.Resize_Image(new_thumb_path, thumb_width, -1, System.Drawing.Imaging.ImageFormat.Jpeg); //delete file System.IO.FileInfo del_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_post" + extension); del_file.Delete(); p_celeb.celeb_image = p_celeb.celeb_image + fileInf.Extension; // save post after image is done celebsManager.hyDB.newsCelebs.AddObject(p_celeb); celebsManager.hyDB.SaveChanges(); } return(RedirectPermanent("/NewsManagement/homeCelebs")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult SaveGenre(int Genre_ID, string GenreName, int Playlist_ID, int User_ID, HttpPostedFileBase ImageThumb, string Username) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.MemberMusicGenreManager genreManager = new hypster_tv_DAL.MemberMusicGenreManager(); List <hypster_tv_DAL.MusicGenre> genres_list = new List <hypster_tv_DAL.MusicGenre>(); hypster_tv_DAL.memberManagement memberManager = new hypster_tv_DAL.memberManagement(); //-------------------------------------------------------------------- //save here hypster_tv_DAL.MusicGenre GenreSave = new hypster_tv_DAL.MusicGenre(); GenreSave.Genre_ID = Genre_ID; GenreSave.GenreName = GenreName; GenreSave.Playlist_ID = Playlist_ID; if (Username != "") { GenreSave.User_ID = memberManager.getMemberByUserName(Username).id; } else { GenreSave.User_ID = User_ID; } genreManager.SaveMusicGenre(GenreSave); //-------------------------------------------------------------------- if (ImageThumb != null && ImageThumb.ContentLength > 0) { var extension = System.IO.Path.GetExtension(ImageThumb.FileName); var path = System.IO.Path.Combine(Server.MapPath("~/uploads"), "music_genre_" + GenreName + extension); ImageThumb.SaveAs(path); hypster_tv_DAL.Image_Resize_Manager image_resizer = new hypster_tv_DAL.Image_Resize_Manager(); image_resizer.Resize_Image(path, 230, 135, System.Drawing.Imaging.ImageFormat.Jpeg); image_resizer.Crop_Image(path, 230, 135, System.Drawing.Imaging.ImageFormat.Jpeg); System.IO.FileInfo file_slide = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "music_genre_" + GenreName + extension); file_slide.CopyTo(System.Configuration.ConfigurationManager.AppSettings["MusicGenreStorage_Path"] + "\\" + GenreSave.GenreName + file_slide.Extension, true); //delete file System.IO.FileInfo del_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "music_genre_" + GenreName + extension); del_file.Delete(); } return(RedirectPermanent("/WebsiteManagement/manageGenres")); } else { return(RedirectPermanent("/home/")); } }
public ActionResult AddNewSlide(int Manual_ID, string Slide_Header, HttpPostedFileBase Slide_Image, int Slide_SortOrder) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.manualManagement manualManager = new hypster_tv_DAL.manualManagement(); hypster_tv_DAL.Manual currManual = new hypster_tv_DAL.Manual(); currManual = manualManager.GetManualByID(Manual_ID); hypster_tv_DAL.Manual_Slide slide = new hypster_tv_DAL.Manual_Slide(); slide.Manual_Slide_Manual_ID = Manual_ID; slide.Manual_Slide_Header = Slide_Header; string img_name_guid = Guid.NewGuid().ToString(); if (Slide_Image.FileName != null && Slide_Image.FileName != "") { System.IO.DirectoryInfo dirInf = new System.IO.DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["ManualsStorage_Path"] + "\\" + currManual.Manual_Guid); if (dirInf.Exists == false) { dirInf.Create(); } var extension = System.IO.Path.GetExtension(Slide_Image.FileName); string tmp_image_path = System.Configuration.ConfigurationManager.AppSettings["ManualsStorage_Path"] + "\\" + currManual.Manual_Guid + "\\TMP_" + img_name_guid + extension; string perm_image_path = System.Configuration.ConfigurationManager.AppSettings["ManualsStorage_Path"] + "\\" + currManual.Manual_Guid + "\\" + img_name_guid + extension; Slide_Image.SaveAs(tmp_image_path); hypster_tv_DAL.Image_Resize_Manager imageResizer = new hypster_tv_DAL.Image_Resize_Manager(); imageResizer.Resize_Image(tmp_image_path, 1024, -1, System.Drawing.Imaging.ImageFormat.Jpeg, perm_image_path, 70L); System.IO.FileInfo file_del = new System.IO.FileInfo(tmp_image_path); file_del.Delete(); //IMAGE slide.Manual_Slide_Image = img_name_guid + extension; } slide.Manual_Slide_Date = DateTime.Now; slide.Manual_Slide_SortOrder = Slide_SortOrder; slide.Manual_Slide_Active = 1; manualManager.AddNewManualSlide(slide); return(RedirectPermanent("/WebsiteManagement/manageManuals")); } else { return(RedirectPermanent("/home/")); } }
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 Edit(HttpPostedFileBase file, hypster_tv_DAL.videoClip p_clip) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.videoClipManager_Admin videoManager = new hypster_tv_DAL.videoClipManager_Admin(); bool isEditingAllowed = true; // //check existing clip before editing //------------------------------------------------------------------------------------------------------------------------------- hypster_tv_DAL.videoClip checkClip = new hypster_tv_DAL.videoClip(); checkClip = videoManager.getVideoByGUID(p_clip.Guid); // if old status was pending and now moving to another status need to move video file from pending directory if (checkClip.Status == -1 && p_clip.Status != -1) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(System.Configuration.ConfigurationManager.AppSettings["videoClipsPending_Path"] + "\\" + p_clip.Guid + ".flv"); if (fileInfo.Exists) { fileInfo.MoveTo(System.Configuration.ConfigurationManager.AppSettings["videoClipsStorage_Path"] + "\\" + p_clip.Guid + ".flv"); } else { isEditingAllowed = false; //do not allow editing since it PENDING video with not supported video encoding } } //------------------------------------------------------------------------------------------------------------------------------- // //editing //------------------------------------------------------------------------------------------------------------------------------- if (isEditingAllowed) { if (file != null && file.ContentLength > 0) { var extension = ".png"; //System.IO.Path.GetExtension(file.FileName); var path = System.IO.Path.Combine(Server.MapPath("~/uploads"), "new_video_cover" + extension); file.SaveAs(path); string image_guid = p_clip.Guid; // // resize image int video_thumb_width = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["videoThumbnail_Width"]); int video_thumb_height = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["videoThumbnail_Height"]); hypster_tv_DAL.Image_Resize_Manager image_resizer = new hypster_tv_DAL.Image_Resize_Manager(); image_resizer.Resize_Image(path, video_thumb_width, video_thumb_height, System.Drawing.Imaging.ImageFormat.Png); System.IO.FileInfo file_slide = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_video_cover" + extension); file_slide.CopyTo(System.Configuration.ConfigurationManager.AppSettings["videoCoversStorage_Path"] + "\\" + image_guid + file_slide.Extension, true); //delete file System.IO.FileInfo del_file = new System.IO.FileInfo(Server.MapPath("~/uploads") + "\\" + "new_video_cover" + extension); del_file.Delete(); } //edit video videoManager.EditVideo(p_clip); } //------------------------------------------------------------------------------------------------------------------------------- return(RedirectToAction(p_clip.Guid)); } else { return(RedirectPermanent("/home/")); } }