protected void rejectBtn_Click(object sender, EventArgs e) { // if the user/moderator clicks the rjectBtn, then we reject and remove the blog entry // Declares an UserEntryFileReaderWriter instance that allows for modification on the UserEntryNew text file UserEntryFileReaderWriter entryReaderWriter = new UserEntryFileReaderWriter(Path.GetFullPath(Server.MapPath("~\\files\\UserEntryNew.txt"))); // removes the entry at the current entryNumber entryReaderWriter.removeEntryDataAtLineNumber(entryNumber); // Redirects to a moderator's reject page that confirms that the entry is gone Response.Redirect("Moderator_Entry_Reject.aspx"); }
protected void acceptBtn_Click(object sender, EventArgs e) { // if the user/moderator clicks the acceptBtn, we enter this method that "cuts and pastes" the entry into to correct entry file // Declares an UserEntryFileReaderWriter instance that allows for modification on the UserEntryNew text file UserEntryFileReaderWriter entryReaderWriter = new UserEntryFileReaderWriter(Path.GetFullPath(Server.MapPath("~\\files\\UserEntryNew.txt"))); // Declaring a dictionary that holds all the blog information Dictionary <string, string> blogData = entryReaderWriter.getEntryDataAtLineNumber(entryNumber); // removes the entry at the current entryNumber entryReaderWriter.removeEntryDataAtLineNumber(entryNumber); // Declares a string that will hold the full path of the approiate text file that the blog entry will save to. string storeFilePath = ""; // now to determine which file the blog entry needs to save to from the blog information collected. // This will set the file path accordingly if (blogData["store"].Equals("Farmers")) { //if the store is farmers, set the file path to the farmers entry file (Absolute) storeFilePath = Path.GetFullPath(Server.MapPath("~\\files\\FarmersUserEntry.txt")); } else if (blogData["store"].Equals("KMart")) { // if the store is KMart, set the file path to the kmart entry file (Absolute) storeFilePath = Path.GetFullPath(Server.MapPath("~\\files\\KmartUserEntry.txt")); } else if (blogData["store"].Equals("DSE")) { // if the store is dick smith, set the file path to the DSE entry file (Absolute) storeFilePath = Path.GetFullPath(Server.MapPath("~\\files\\DSEUserEntry.txt")); } else if (blogData["store"].Equals("HarveyNorman")) { // if the store is harvey norman, set the file path to the harvey norman entry file (Absolute) storeFilePath = Path.GetFullPath(Server.MapPath("~\\files\\HarveyNormanUserEntry.txt")); } // Now we need to add the blog entry line to the top of the store's entry files // Declare a string that gets all the text from the store's file path (including new line seperators) string oldUserEntryNewFile = System.IO.File.ReadAllText(storeFilePath); // Declares a string that places the blog entry's data into a parsable format. string newLine = blogData["loginID"] + "," + blogData["unixTime"] + "," + blogData["badExperienceParagraph"]; // Overwrites the store's entry file and places the new data, line seperator and old data in the file therefore // the new data is at the top of the file System.IO.File.WriteAllText(storeFilePath, newLine + "\r\n" + oldUserEntryNewFile); // Redirects the umoderator to an acceptance page that confirm the entry of the Response.Redirect("Moderator_Entry_Accept.aspx"); }