Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data;
- using ForumTableAdapters;
- /// <summary>
- /// Summary description for ForumCategoryBLL
- /// </summary>
- public class ForumBLL
- {
- tblForumCategoriesTableAdapter ForumCategoriesTableAdapter = new tblForumCategoriesTableAdapter();
- tblForumPostsTableAdapter ForumPostsTableAdapter = new tblForumPostsTableAdapter();
- public ForumBLL()
- {
- // TODO: Add constructor logic here
- }
- public DataTable GetForumCategories()
- {
- return ForumCategoriesTableAdapter.GetForumCategories();
- }
- public void CategorySave(string _categoryName, string _categoryDescription)
- {
- DateTime Today = DateTime.Now;
- ForumCategoriesTableAdapter.Insert(_categoryName, GenerateUrlName(_categoryName), _categoryDescription, Today, Today, 0);
- }
- private string GenerateUrlName(string _name)
- {
- string ReturnVal = _name.ToLower();
- ReturnVal = ReturnVal.TrimStart();
- ReturnVal = ReturnVal.TrimEnd();
- ReturnVal = ReturnVal.Replace("æ", "ae");
- ReturnVal = ReturnVal.Replace("ø", "oe");
- ReturnVal = ReturnVal.Replace("å", "aa");
- ReturnVal = ReturnVal.Replace("#", "");
- ReturnVal = ReturnVal.Replace("!", "");
- ReturnVal = ReturnVal.Replace("%", "");
- ReturnVal = ReturnVal.Replace("&", "");
- ReturnVal = ReturnVal.Replace("/", "");
- ReturnVal = ReturnVal.Replace(" ", "-");
- ReturnVal = ReturnVal.Replace("+", "-");
- ReturnVal = ReturnVal.Replace("?", "");
- ReturnVal = ReturnVal.Replace("@", "");
- ReturnVal = ReturnVal.Replace("*", "");
- ReturnVal = ReturnVal.Replace("(", "");
- ReturnVal = ReturnVal.Replace(")", "");
- ReturnVal = ReturnVal.Replace("[", "");
- ReturnVal = ReturnVal.Replace("]", "");
- ReturnVal = ReturnVal.Replace("{", "");
- ReturnVal = ReturnVal.Replace("}", "");
- ReturnVal = ReturnVal.Replace("%", "");
- ReturnVal = ReturnVal.Replace("€", "");
- ReturnVal = ReturnVal.Replace("$", "");
- ReturnVal = ReturnVal.Replace("§", "");
- return ReturnVal;
- }
- private string Check_PostUrlName(string _postUrlName)
- {
- return ForumPostsTableAdapter.Check_PostUrlName(_postUrlName);
- }
- private string Find_PostUrlName(string _postUrlName)
- {
- string UrlName = _postUrlName;
- string NewUrlName = Check_PostUrlName(_postUrlName);
- if (!string.IsNullOrEmpty(NewUrlName))
- {
- int counter = 0;
- bool FoundNewUrlName = false;
- while (FoundNewUrlName == false)
- {
- counter = counter += 1;
- NewUrlName = Check_PostUrlName(UrlName + counter);
- if (string.IsNullOrEmpty(NewUrlName))
- {
- FoundNewUrlName = true;
- NewUrlName = ForumPostsTableAdapter.Check_PostUrlName(NewUrlName);
- }
- }
- }
- if (string.IsNullOrEmpty(NewUrlName))
- {
- return UrlName;
- }
- else
- {
- return NewUrlName;
- }
- }
- public DataTable GetForumPosts(string _postUrlName)
- {
- return ForumPostsTableAdapter.GetForumPosts(_postUrlName);
- }
- public void PostSave(string _postSubject, string _postContent, string _postUserName, string _postUserEmail, string _forumUrlName)
- {
- DateTime Today = DateTime.Now;
- string UrlName = GenerateUrlName(_postSubject);
- string NewUrlName = Find_PostUrlName(UrlName);
- ForumPostsTableAdapter.Insert(_postSubject, NewUrlName, _postContent, Today, Today, 0, _postUserName, _postUserEmail, GetCategoryIdFromUrlName(_forumUrlName));
- }
- public int GetCategoryIdFromUrlName(string _urlName)
- {
- return (int)ForumCategoriesTableAdapter.GetCategoryIdFromUrlName(_urlName);
- }
- private void UpdateCategoryHits(string _urlName)
- {
- // ForumCategoriesTableAdapter.UpdateCategoryHits()
- }
- public DataTable GetForumPost(string _postUrlName)
- {
- return ForumPostsTableAdapter.GetForumPost(_postUrlName);
- }
- private string Check_CategoryUrlName(string _categoryUrlName)
- {
- return ForumCategoriesTableAdapter.Check_CategoryUrlName(_categoryUrlName);
- }
- private string Find_CategoryUrlName(string _categoryUrlName)
- {
- string UrlName = _categoryUrlName;
- string NewUrlName = Check_CategoryUrlName(_categoryUrlName);
- if (!string.IsNullOrEmpty(NewUrlName))
- {
- int counter = 0;
- bool FoundNewUrlName = false;
- while (FoundNewUrlName == false)
- {
- counter = counter += 1;
- NewUrlName = Check_CategoryUrlName(UrlName + counter);
- if (string.IsNullOrEmpty(NewUrlName))
- {
- FoundNewUrlName = true;
- NewUrlName = ForumCategoriesTableAdapter.Check_CategoryUrlName(NewUrlName);
- }
- }
- }
- if (string.IsNullOrEmpty(NewUrlName))
- {
- return UrlName;
- }
- else
- {
- return NewUrlName;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment