public ActionResult Add(long id) { VideoSaveModel model = new VideoSaveModel(); utblVideo _vmodel = new utblVideo(); model.VideoAlbum = objVideoAlbum.GetVideoAlbumByID(id); model.Videos = _vmodel; return(View(model)); }
public string DeleteVideo(long id) { try { utblVideo model = db.utblVideos.Find(id); db.utblVideos.Remove(model); db.SaveChanges(); return("Video Removed"); } catch (Exception) { return("Error: Server error, try again later"); } }
public ActionResult Edit(VideoSaveModel model, HttpPostedFileBase docFile) { utblVideo vid = new utblVideo(); vid = objVideo.GetVideoByID(model.Videos.VideoID); string PrvPath = vid.VideoFilePathDraft; string file_result = ""; var validData = true; if (docFile != null) { string fileResult = FileTypeCheck.IsValidFile(docFile, "Video"); if (!fileResult.Equals("Success")) { ModelState.AddModelError("FileErr", fileResult); validData = false; } else { file_result = SaveFile(docFile, model.Videos.VideoAlbumID); model.Videos.VideoFilePathDraft = FileUrl + "/Videos/" + file_result; if (file_result.Contains("Error")) { TempData["ErrMsg"] = file_result; return(View(model)); } } } if (ModelState.IsValid && validData) { //model.Videos.VideoAlbumID = model.VideoAlbum.VideoAlbumID; model.Videos.TransDate = DateTime.Now; model.Videos.UserID = User.Identity.Name; string result = objVideo.SaveVideo(model.Videos); if (result.Contains("Success")) { if (file_result != "") { DeleteFile(PrvPath); } objSite.AddAuditLog("utblVideos", "Videos Updated", IPAddressGetter.GetIPAddress(), User.Identity.Name); TempData["ErrMsg"] = result; return(RedirectToAction("index", "Video", new { Area = "Admin", AlbumID = model.Videos.VideoAlbumID })); } TempData["ErrMsg"] = result; } model.VideoAlbum = objVideoAlbum.GetVideoAlbumByID(model.Videos.VideoAlbumID); return(View(model)); }
//[AntiXSRFFilter] public ActionResult Delete(long id, long AlbumID) { utblVideo model = new utblVideo(); model = objVideo.GetVideoByID(id); string PrvPath = model.VideoFilePathDraft; string result = objVideo.DeleteVideo(id); if (!result.ToLower().Contains("Error")) { objSite.AddAuditLog("utblVideos", "Video Removed", IPAddressGetter.GetIPAddress(), User.Identity.Name, id); DeleteFile(PrvPath); TempData["ErrMsg"] = "Success: Data Removed Succesfully !"; } else { TempData["ErrMsg"] = result; } return(RedirectToAction("index", "Video", new { Area = "Admin", AlbumID = AlbumID })); }
public string SaveVideo(utblVideo model) { var parVideoID = new SqlParameter("@VideoID", model.VideoID); var parVideoTitle = new SqlParameter("@VideoTitle", model.VideoTitle); var parVideoAlbumID = new SqlParameter("@VideoAlbumID", model.VideoAlbumID); var parVideoFilePathThumb = new SqlParameter("@VideoFilePathThumb", DBNull.Value); if (model.VideoFilePathDraft != null) { parVideoFilePathThumb = new SqlParameter("@VideoFilePathThumb", model.VideoFilePathDraft); } var parVideoFilePathNormal = new SqlParameter("@VideoFilePathNormal", DBNull.Value); if (model.VideoFilePathPublished != null) { parVideoFilePathNormal = new SqlParameter("@VideoFilePathNormal", model.VideoFilePathPublished); } var parIsAlbumCover = new SqlParameter("@IsAlbumCover", model.IsAlbumCover); var parTransDate = new SqlParameter("@TransDate", model.TransDate); var parUserID = new SqlParameter("@UserID", model.UserID); return(db.Database.SqlQuery <string>("udspVideoSave @VideoID,@VideoTitle, @VideoAlbumID, @VideoFilePathThumb,@VideoFilePathNormal,@IsAlbumCover, @TransDate, @UserID", parVideoID, parVideoTitle, parVideoAlbumID, parVideoFilePathThumb, parVideoFilePathNormal, parIsAlbumCover, parTransDate, parUserID).FirstOrDefault()); }