public string addNewTag2db(string[] tag) { VideoBackendViewModel allTags = new VideoBackendViewModel(); allTags = getAllTags(allTags); try { using (SqlConnection connection = new SqlConnection(QUToolsUtilities.GetConnectionString("internet"))) { connection.Open(); string sqlCmd = @"INSERT INTO {0} (tagname) VALUES (@tagname);" ; sqlCmd = String.Format(sqlCmd, tag[1]); SqlCommand command = new SqlCommand(sqlCmd, connection); command.Parameters.Add("@tagname", SqlDbType.VarChar).Value = tag[2]; command.ExecuteNonQuery(); connection.Close(); } } catch (Exception e) { return(e.Message); } return("Success"); }
public IActionResult AddLink(string alltags, string title, string URL, string duration, DateTime datecompleted, string videotype, string description) { bool result = login.checkSession(); if (result == false) { curPage.errorMsg = "Either you do not have access to these tools or your session has timed out..."; TempData["error"] = curUser.returnMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } bool _test1 = String.IsNullOrEmpty(title); bool _test2 = String.IsNullOrEmpty(URL); bool _test3 = String.IsNullOrEmpty(duration); bool _test4 = String.IsNullOrEmpty(videotype); bool _test5 = String.IsNullOrEmpty(description); if (_test1 || _test2 || _test3 || _test4 || _test5) { TempData["error"] = "It appears you missed a field. Make sure all fields are filled out"; return(RedirectToAction("AddLink", "VideoBackend")); } AccountManager sqlStuff = new AccountManager(); login userInformation = new login(); curUser.username = login.returnUsername(); curUser.userTable = userdb; curUser = AccountManager.checkAdmin(curUser); if (curUser.Admin != "Yes") { curPage.errorMsg = "An error has occured, please try again. "; //AccountManager curUser = new AccountManager(); TempData["error"] = curPage.errorMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } VideoBackendViewModel videoMetaData = new VideoBackendViewModel(); VideoBackEnd VBM = new VideoBackEnd(); string[] tagArray; videoMetaData.VideoName = title; videoMetaData.URL = URL; videoMetaData.Duration = duration; videoMetaData.DateCompleted = datecompleted; videoMetaData.VideoType = videotype; videoMetaData.VideoDescription = description; tagArray = VBM.parseTags(alltags); string x = VBM.processEntry(videoMetaData, tagArray, curUser.username); TempData["error"] = x; return(RedirectToAction("AddLink", "VideoBackend", curPage)); }
public string processEntry(VideoBackendViewModel newVideolink, string[] tags, string username) { string vidID; if (newVideolink.vidID == null) { vidID = VidIDMaker(newVideolink.VideoName); } else { vidID = newVideolink.vidID; } string y = addVideo2db(newVideolink, vidID, username); if (y != "true") { return("280: " + y); } foreach (string i in tags) { if (i != "") { string[] tagArray = processRawTag(i); bool x = addTag2db(tagArray, vidID); if (x == false) { break; } } } return("Success"); }
public VideoBackendViewModel getAllTags(VideoBackendViewModel TagList) { //VideoBackendViewModel TagList = new VideoBackendViewModel(); TagList.ProgramTags = new List <VideoBackendViewModel>(); TagList.OtherTags = new List <VideoBackendViewModel>(); TagList.PillarsTags = new List <VideoBackendViewModel>(); TagList.SchoolTags = new List <VideoBackendViewModel>(); TagList.EventsTags = new List <VideoBackendViewModel>(); TagList.AthleticsTags = new List <VideoBackendViewModel>(); TagList.GeoTags = new List <VideoBackendViewModel>(); TagList.SchoolTags = getTags("QUTool_BSIC_Vid_School"); TagList.ProgramTags = getTags("QUTool_BSIC_Vid_Program"); TagList.OtherTags = getTags("QUTool_BSIC_Vid_OtherTags"); TagList.PillarsTags = getTags("QUTool_BSIC_Vid_Pillars"); TagList.EventsTags = getTags("QUTool_BSIC_Vid_Events"); TagList.AthleticsTags = getTags("QUTool_BSIC_Vid_Athletics"); TagList.GeoTags = getTags("QUTool_BSIC_Vid_Geo"); return(TagList); }
public VideoBackendViewModel getVideoTags(string vidID) { VideoBackendViewModel VidTags = new VideoBackendViewModel(); return(VidTags); }
public IActionResult jayAdmin(string deleteThese) { #region login bool result = login.checkSession(); if (result == false) { curPage.errorMsg = "Either you do not have access to these tools or your session has timed out..."; TempData["error"] = curUser.returnMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } AccountManager sqlStuff = new AccountManager(); login userInformation = new login(); curUser.username = login.returnUsername(); curUser.userTable = userdb; curUser = AccountManager.checkAdmin(curUser); if (curUser.Admin != "Yes" && curUser.username == "jamunro") { curPage.errorMsg = "An error has occured, please try again. "; //AccountManager curUser = new AccountManager(); TempData["error"] = curPage.errorMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } #endregion VideoBackendViewModel videodata = new VideoBackendViewModel(); VideoBackEnd videomethods = new VideoBackEnd(); string[] tags = deleteThese.Split('|'); foreach (var t in tags) { if (t != "") { videomethods.deletetag(t); } } TempData["error"] = " Deleted " + deleteThese; videodata = videomethods.jayAllTags(videodata); return(View(videodata)); }
public VideoBackendViewModel jayAllTags(VideoBackendViewModel TagList) { //VideoBackendViewModel TagList = new VideoBackendViewModel(); TagList.GeneralTagList = new List <VideoBackendViewModel>(); TagList.GeneralTagList.AddRange(getTags("QUTool_BSIC_Vid_School")); TagList.GeneralTagList.AddRange(getTags("QUTool_BSIC_Vid_Program")); TagList.GeneralTagList.AddRange(getTags("QUTool_BSIC_Vid_OtherTags")); TagList.GeneralTagList.AddRange(getTags("QUTool_BSIC_Vid_Pillars")); TagList.GeneralTagList.AddRange(getTags("QUTool_BSIC_Vid_Events")); TagList.GeneralTagList.AddRange(getTags("QUTool_BSIC_Vid_Athletics")); TagList.GeneralTagList.AddRange(getTags("QUTool_BSIC_Vid_Geo")); return(TagList); }
public bool addTag2db(string[] tag, string vidID) { VideoBackendViewModel allTags = new VideoBackendViewModel(); allTags = getAllTags(allTags); /*var theTag = allTags.SchoolTags.First(x => x.Tag_ID == tag[1]); * * if (theTag.Tag_ID == null) * return false; */ try { using (SqlConnection connection = new SqlConnection(QUToolsUtilities.GetConnectionString("internet"))) { connection.Open(); string sqlCmd = @"INSERT INTO {0} (vidID, tagID) VALUES (@vidID, @tagID);" ; sqlCmd = String.Format(sqlCmd, tag[0]); SqlCommand command = new SqlCommand(sqlCmd, connection); int tagID = Convert.ToInt16(tag[1]); command.Parameters.Add("@vidID", SqlDbType.VarChar).Value = vidID; command.Parameters.Add("@tagID", SqlDbType.Int).Value = tagID; command.ExecuteNonQuery(); connection.Close(); } } catch (Exception e) { return(false); } return(true); }
public IActionResult EditLink(string id) { bool result = login.checkSession(); if (result == false) { curPage.errorMsg = "Either you do not have access to these tools or your session has timed out..."; TempData["error"] = curUser.returnMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } AccountManager sqlStuff = new AccountManager(); login userInformation = new login(); curUser.username = login.returnUsername(); curUser.userTable = userdb; curUser = AccountManager.checkAdmin(curUser); if (curUser.Admin != "Yes") { curPage.errorMsg = "An error has occured, please try again. "; //AccountManager curUser = new AccountManager(); TempData["error"] = curPage.errorMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } VideoBackendViewModel videodata = new VideoBackendViewModel(); VideoBackEnd videomethods = new VideoBackEnd(); videodata = videomethods.listVideos(id); videodata = videomethods.getAllTags(videodata); videodata.vidID = id; videodata = videomethods.getTagsForVideo(videodata); TempData["error"] = videodata.returnMsg; return(View(videodata)); }
public IActionResult AddLink() { bool result = login.checkSession(); if (result == false) { curPage.errorMsg = "Either you do not have access to these tools or your session has timed out..."; TempData["error"] = curUser.returnMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } AccountManager sqlStuff = new AccountManager(); login userInformation = new login(); curUser.username = login.returnUsername(); curUser.userTable = userdb; curUser = AccountManager.checkAdmin(curUser); if (curUser.Admin != "Yes") { curPage.errorMsg = "An error has occured, please try again. "; //AccountManager curUser = new AccountManager(); TempData["error"] = curPage.errorMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } VideoBackendViewModel taglist = new VideoBackendViewModel(); VideoBackEnd VBM = new VideoBackEnd(); taglist = VBM.getAllTags(taglist); return(View(taglist)); }
public string addVideo2db(VideoBackendViewModel videoInfo, string vidID, string username) { //try //{ using (SqlConnection connection = new SqlConnection(QUToolsUtilities.GetConnectionString("internet"))) { connection.Open(); string sqlCmd = "INSERT INTO QUTool_BSIC_Vid_VideoList (VidID, VideoName, VideoDescription, URL, DateCompleted, Duration, VideoType, AddedDate, AddedBy)" + "VALUES (@vidID, @VideoName, @VideoDescription, @URL, @DateCompleted, " + "@Duration, @VideoType, @AddedDate, @username);"; SqlCommand command = new SqlCommand(sqlCmd, connection); command.Parameters.Add("@vidID", SqlDbType.VarChar).Value = vidID; command.Parameters.Add("@VideoName", SqlDbType.VarChar).Value = videoInfo.VideoName; command.Parameters.Add("@VideoDescription", SqlDbType.VarChar, 9999).Value = videoInfo.VideoDescription; command.Parameters.Add("@URL", SqlDbType.VarChar).Value = videoInfo.URL; command.Parameters.Add("@DateCompleted", SqlDbType.DateTime).Value = videoInfo.DateCompleted; command.Parameters.Add("@Duration", SqlDbType.VarChar).Value = videoInfo.Duration; command.Parameters.Add("@VideoType", SqlDbType.VarChar).Value = videoInfo.VideoType; command.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = DateTime.Now; command.Parameters.Add("@username", SqlDbType.VarChar).Value = username; command.ExecuteNonQuery(); connection.Close(); } //} //catch (Exception e) //{ // return e.Message.ToString(); //} return("true"); }
public IActionResult addTag(string alltags, string delTags) { bool result = login.checkSession(); if (result == false) { curPage.errorMsg = "Either you do not have access to these tools or your session has timed out..."; TempData["error"] = curUser.returnMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } AccountManager sqlStuff = new AccountManager(); login userInformation = new login(); curUser.username = login.returnUsername(); curUser.userTable = userdb; curUser = AccountManager.checkAdmin(curUser); if (curUser.Admin != "Yes") { curPage.errorMsg = "An error has occured, please try again. "; //AccountManager curUser = new AccountManager(); TempData["error"] = curPage.errorMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } VideoBackendViewModel videoMetaData = new VideoBackendViewModel(); VideoBackEnd VBM = new VideoBackEnd(); if (delTags != "na") { string[] tags = delTags.Split('|'); foreach (var t in tags) { if (t != "") { VBM.deletetag(t); } } TempData["error"] = "Deleted Tags"; return(RedirectToAction("MainMenu", "VideoBackend", curPage)); } if (alltags == "na") { TempData["error"] = "No tags entered..."; return(RedirectToAction("MainMenu", "VideoBackend", curPage)); } string[] tagArray; tagArray = VBM.parseTags(alltags); string x = VBM.processNewTags(tagArray); TempData["error"] = "Success"; if (x != "Success") { TempData["error"] = "Unable to add. " + x; } return(RedirectToAction("MainMenu", "VideoBackend", curPage)); }
public IActionResult EditLink(string alltags, string vidID, string title, string URL, string duration, DateTime datecompleted, string videotype, string description, string delete) { bool result = login.checkSession(); if (result == false) { curPage.errorMsg = "Either you do not have access to these tools or your session has timed out..."; TempData["error"] = curUser.returnMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } AccountManager sqlStuff = new AccountManager(); login userInformation = new login(); curUser.username = login.returnUsername(); curUser.userTable = userdb; curUser = AccountManager.checkAdmin(curUser); if (curUser.Admin != "Yes") { curPage.errorMsg = "An error has occured, please try again. "; //AccountManager curUser = new AccountManager(); TempData["error"] = curPage.errorMsg; return(RedirectToAction("Index", "VideoBackend", curPage)); } VideoBackendViewModel videoMetaData = new VideoBackendViewModel(); VideoBackEnd VBM = new VideoBackEnd(); try { string[] tagArray; videoMetaData.VideoName = title; videoMetaData.URL = URL; videoMetaData.Duration = duration; videoMetaData.DateCompleted = datecompleted; videoMetaData.VideoType = videotype; videoMetaData.VideoDescription = description; videoMetaData.vidID = vidID; tagArray = VBM.parseTags(alltags); string y = VBM.cleanLinkEntrys(vidID); if (delete == "1") { TempData["error"] = y; return(RedirectToAction("ListLinks", "VideoBackend")); } if (y == "Success") { string x = VBM.processEntry(videoMetaData, tagArray, curUser.username); TempData["error"] = x; } return(RedirectToAction("ListLinks", "VideoBackend", curPage)); } catch (Exception e) { TempData["error"] = e.Message; return(RedirectToAction("ListLinks", "VideoBackend", curPage)); } }
/* * * * QUTool_BSIC_Vid_VideoList * VidID int, * VideoName varchar(250), * VideoDescription varchar(2000), * URL varchar(100), * DateCompleted date, * Duration int, * VideoType varchar(50), * * TABLES IN USE * All the following will have VidID and tagID * QUTool_BSIC_Vid_ProgramVids * QUTool_BSIC_Vid_SchoolVids * QUTool_BSIC_Vid_EventsVids * QUTool_BSIC_Vid_PillarVids * QUTool_BSIC_Vid_OtherTagsVids * QUTool_BSIC_Vid_GeoVids * QUTool_BSIC_Vid_AthleticsVids * * All will have tagID and tagname. * QUTool_BSIC_Vid_Program * QUTool_BSIC_Vid_School * QUTool_BSIC_Vid_Events * QUTool_BSIC_Vid_Pillars * QUTool_BSIC_Vid_Geo * QUTool_BSIC_Vid_Athletics * QUTool_BSIC_Vid_OtherTags */ public VideoBackendViewModel getTagsForVideo(VideoBackendViewModel tagList) { tagList.GeneralTagList = new List <VideoBackendViewModel>(); string sqlCmd = @"select sv.VidID,s.tagID, s.tagname, 'school' as 'group' from QUTool_BSIC_Vid_SchoolVids sv left join QUTool_BSIC_Vid_School s on s.tagID = sv.tagID where VidID = @vidID union select pv.VidID, p.tagID, p.tagname, 'Program' as 'group' from QUTool_BSIC_Vid_ProgramVids pv left join QUTool_BSIC_Vid_Program p on p.tagID = pv.tagID where VidID = @vidID union select plv.VidID, pl.tagID, pl.tagname, 'Pillars' as 'group' from QUTool_BSIC_Vid_PillarVids plv left join QUTool_BSIC_Vid_Pillars pl on pl.tagID = plv.tagID where VidID = @vidID union select ov.VidID, o.tagID, o.tagname, 'OtherTags' as 'group' from QUTool_BSIC_Vid_OtherTagsVids ov left join QUTool_BSIC_Vid_OtherTags o on o.tagID = ov.tagID where VidID = @vidID union select gv.VidID, g.tagID, g.tagname, 'Geographical' as 'group' from QUTool_BSIC_Vid_GeoVids gv left join QUTool_BSIC_Vid_Geo g on g.tagID = gv.tagID where VidID =@vidID union select ev.VidID, e.tagID, e.tagname, 'Events' as 'group' from QUTool_BSIC_Vid_EventsVids ev left join QUTool_BSIC_Vid_Events e on e.tagID = ev.tagID where VidID = @vidID union select av.VidID, a.tagID, a.tagname av, 'Athletics' as 'group' from QUTool_BSIC_Vid_AthleticsVids av left join QUTool_BSIC_Vid_Athletics a on a.tagID = av.tagID where VidID = @vidID" ; try { using (SqlConnection connection = new SqlConnection(QUToolsUtilities.GetConnectionString("internet"))) { connection.Open(); SqlCommand command = new SqlCommand(sqlCmd, connection); command.Parameters.Add("@vidID", SqlDbType.VarChar).Value = tagList.vidID; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { tagList.GeneralTagList.Add(new VideoBackendViewModel { Tag_ID = reader["tagID"].ToString(), Tag = reader["tagname"].ToString(), Tag_Group = reader["group"].ToString() }); } } connection.Close(); } } catch (Exception e) { tagList.returnMsg = e.Message.ToString(); return(tagList); } return(tagList); }
public VideoBackendViewModel listVideos(string searchParam) { // Maybe date? VideoBackendViewModel vidObj = new VideoBackendViewModel(); vidObj.VideoInfo = new List <VideoBackendViewModel>(); string sqlCmd = "select * from QUTool_BSIC_Vid_VideoList"; bool search = false; if (searchParam != "all") { sqlCmd = "select * from QUTool_BSIC_Vid_VideoList where vidid = @vidid"; search = true; } try { using (SqlConnection connection = new SqlConnection(QUToolsUtilities.GetConnectionString("internet"))) { connection.Open(); ///sqlCmd = String.Format(sqlCmd, category); SqlCommand command = new SqlCommand(sqlCmd, connection); if (search == true) { command.Parameters.Add("@vidid", SqlDbType.VarChar).Value = searchParam; } using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { vidObj.VideoInfo.Add(new VideoBackendViewModel { VideoName = QUToolsUtilities.HtmlDecode(reader["Videoname"].ToString()), VideoDescription = QUToolsUtilities.HtmlDecode(reader["VideoDescription"].ToString()), URL = QUToolsUtilities.HtmlDecode(reader["URL"].ToString()), DateCompleted = Convert.ToDateTime(reader["DateCompleted"]), Duration = QUToolsUtilities.HtmlDecode(reader["Duration"].ToString()), VideoType = QUToolsUtilities.HtmlDecode(reader["VideoType"].ToString()), Addedby = reader["AddedBy"].ToString(), UpdatedDate = Convert.ToDateTime(reader["UpdatedDate"]), AddedDate = Convert.ToDateTime(reader["AddedDate"]), vidID = reader["VidID"].ToString() }); } } connection.Close(); } } catch (Exception e) { vidObj.returnMsg = e.Message.ToString(); return(vidObj); } return(vidObj); }