/// <summary> /// Create a hashtable for Recipe Category dropdownlist /// </summary> private static void createCategoryListRecipe() { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); //Get data IDataReader dr = FetchData.GetRecipeCategoryDropdownlist; try { Hashtable ht = new Hashtable(); while (dr.Read()) { ht.Add(dr["CAT_ID"].ToString(), dr["CAT_TYPE"].ToString()); _CategoryListRecipe = ht; } } catch (Exception ex) { throw ex; } //Release allocated memory dr.Close(); FetchData = null; }
/// <summary> /// Get data /// </summary> public override void fillup() { try { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); //Get email and SMTP configuration IDataReader dr = FetchData.GetConfiguration; dr.Read(); if (dr["Email"] != DBNull.Value) { this._FromAdminEmail = (string)dr["Email"]; } if (dr["SmtpServer"] != DBNull.Value) { this._ToAdminEmail = (string)dr["SmtpServer"]; //This use to be the STMP server, but now changed to ToAdminEmail } dr.Close(); dr = null; } catch (Exception ex) { throw ex; } }
/// <summary> /// Get recipe name, author, date, hits, rating, ingredients, instructions and other field from the DB matching the Recipe ID provided. /// </summary> /// <param name="ID">Recipe ID</param> public override void fillup() { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); try { IDataReader dr = FetchData.GetHomepageRecipeoftheDay; dr.Read(); if (dr["ID"] != DBNull.Value) { this._ID = (int)dr["ID"]; } if (dr["Name"] != DBNull.Value) { this._RecipeName = (string)dr["Name"]; } if (dr["CAT_ID"] != DBNull.Value) { this._CatID = (int)dr["CAT_ID"]; } if (dr["NO_RATES"] != DBNull.Value) { this._NoRates = dr["NO_RATES"].ToString(); } if (dr["HITS"] != DBNull.Value) { this._Hits = (int)dr["HITS"]; } if (dr["Rates"] != DBNull.Value) { this._Rating = dr["Rates"].ToString(); } if (dr["Category"] != DBNull.Value) { this._Category = (string)dr["Category"]; } if (dr["Ingredients"] != DBNull.Value) { this._Ingredients = (string)dr["Ingredients"]; } if (dr["Instructions"] != DBNull.Value) { this._Instructions = (string)dr["Instructions"]; } //Release allocated memory dr.Close(); dr = null; } catch (Exception ex) { throw ex; } FetchData = null; }
/// <summary> /// Return GetData /// </summary> /// <returns></returns> private static IDataReader GetData(int CatId) { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); //Get data IDataReader dr = FetchData.GetRelatedRecipe(CatId); return dr; FetchData = null; }
/// <summary> /// Return Newest Recipe Side Panel /// </summary> public static ExtendedCollection<Article> GetArticle(int Top) { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); ExtendedCollection<Article> GetArticles = new ExtendedCollection<Article>(); string Key = "Newest_Articles"; if (Caching.Cache[Key] != null) { GetArticles = (ExtendedCollection<Article>)Caching.Cache[Key]; } else { IDataReader dr = FetchData.GetNewestArticleSidePanel(Top); while (dr.Read()) { Article item = new Article(); item.ID = (int)dr["ID"]; if (dr["Title"] != DBNull.Value) { item.Title = (string)dr["Title"]; } if (dr["CAT_NAME"] != DBNull.Value) { item.Category = (string)dr["CAT_NAME"]; } if (dr["Post_Date"] != DBNull.Value) { item.Date = (DateTime)(dr["Post_Date"]); } if (dr["HITS"] != DBNull.Value) { item.Hits = (int)dr["HITS"]; } GetArticles.Add(item); Caching.CahceData(Key, GetArticles); } dr.Close(); } return GetArticles; FetchData = null; }
/// <summary> /// Returns Most Popular Recipes Side Menu /// </summary> public ExtendedCollection<Recipe> GetPopularRecipe() { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); ExtendedCollection<Recipe> GetRecipe = new ExtendedCollection<Recipe>(); string Key = "MostPopular_RecipesSideMenu_" + CatID.ToString(); if (Caching.Cache[Key] != null) { GetRecipe = (ExtendedCollection<Recipe>)Caching.Cache[Key]; } else { IDataReader dr = FetchData.GetMostpopularRecipesSideMenu(CatID, Top); while (dr.Read()) { Recipe item = new Recipe(); item.ID = (int)dr["ID"]; if (dr["Name"] != DBNull.Value) { item.RecipeName = (string)dr["Name"]; } if (dr["Category"] != DBNull.Value) { item.Category = (string)dr["Category"]; } if (dr["HITS"] != DBNull.Value) { item.Hits = (int)dr["HITS"]; } GetRecipe.Add(item); Caching.CahceData(Key, GetRecipe); } dr.Close(); } return GetRecipe; FetchData = null; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Validate admin session username and password by comparing them to the admin user database record. UserNameVal.ValidateAdminUserNameandPass(); //Get admin username from the sessioan variable and place it in the label. lblusername.Text = "Welcome Admin: " + UserNameVal.AdminUsername; if (Request.QueryString["prevedit"] != null) { btn1.Visible = false; btn2.Visible = true; } else { btn1.Visible = true; btn2.Visible = false; } //Instantiate database field ArticleDetail Article = new ArticleDetail(); Article.WhatPageID = (int)Util.Val(Request.QueryString["show"]); //Parameter 2 = we are dealing with the admin/updatearticle.aspx. Article.ID = (int)Util.Val(Request.QueryString["aid"]); //Fill up database fields Article.fillup(); string categoryname; categoryname = Article.Category; lbtitle.Text = Article.Title; lbcatname2.Text = Article.Category; Title.Value = Article.Title; Content.Value = Util.FormatText(Article.Content); Summary.Value = Util.FormatText(Article.Summary); Keyword.Value = Article.Keyword; Author.Value = Article.Author; CAT_ID.Value = Article.CatID.ToString(); //Release allocated memory myBL = null; Util = null; Article = null; } }
/// <summary> /// Show or hide recipe comment /// </summary> public override void fillup() { //Find control Panel Panel1 = (Panel)(placeholder.FindControl("Panel1")); Image CommentImg = (Image)(placeholder.FindControl("CommentImg")); HyperLink CommentLink = (HyperLink)(placeholder.FindControl("CommentLink")); //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); try { IDataReader dr = FetchData.GetConfiguration; dr.Read(); //Show hide comment if (dr["HideShowComment"] != DBNull.Value) { this._ShowHideComment = (int)dr["HideShowComment"]; } dr.Close(); dr = null; if (IsShowHideComment) { //If true, display recipe comments, else hide. //Get datasourse RepeaterName.DataSource = RecipeCommentProvider.GetComments(ID); RepeaterName.DataBind(); Panel1.Visible = true; } else { Panel1.Visible = false; CommentImg.Visible = false; CommentLink.Visible = false; } } catch (Exception ex) { throw ex; } FetchData = null; }
/// <summary> /// Return Recipe Category /// </summary> public static ExtendedCollection<Recipe> GetRecipeCategoryMenu() { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); ExtendedCollection<Recipe> GetRecipe = new ExtendedCollection<Recipe>(); string Key = "RecipeCategory_SideMenu"; if (Caching.Cache[Key] != null) { GetRecipe = (ExtendedCollection<Recipe>)Caching.Cache[Key]; } else { IDataReader dr = FetchData.GetRecipeCategoryList_SideMenu; while (dr.Read()) { Recipe item = new Recipe(); item.CatID = (int)dr["CAT_ID"]; if (dr["CAT_TYPE"] != DBNull.Value) { item.Category = (string)dr["CAT_TYPE"]; } if (dr["REC_COUNT"] != DBNull.Value) { item.RecordCount = (int)(dr["REC_COUNT"]); } GetRecipe.Add(item); Caching.CahceData(Key, GetRecipe); } dr.Close(); } return GetRecipe; FetchData = null; }
/// <summary> /// Perform Admin username and password session validation. /// </summary> public static void ValidateAdminUserNameandPass() { //Instantiate utility object Utility Util = new Utility(); Blogic myBL = new Blogic(); //If it is null, redirect to login page. if ((HttpContext.Current.Session["adminuserid"] == null) && (HttpContext.Current.Session["adminpassword"] == null)) { //Redirect to admin login page. Util.PageRedirect(6); return; } try { //Get admin username stored in the database IDataReader dr = myBL.AdminGetCredentialSessionValidation; dr.Read(); //Check whether admin username or password match from the admin user database, else redirect to the login page. if (HttpContext.Current.Session["adminuserid"].ToString() != dr["uname"].ToString() || HttpContext.Current.Session["adminpassword"].ToString() != dr["password"].ToString()) { //Redirect to admin login page. Util.PageRedirect(6); } //Release allocated memory. dr.Close(); dr = null; Util = null; } catch (Exception ex) { throw ex; } }
/// <summary> /// Return Recipe Comment /// </summary> public static ExtendedCollection<Comment> GetComments(int ID) { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); ExtendedCollection<Comment> GetComment = new ExtendedCollection<Comment>(); IDataReader dr = FetchData.GetCommentsRecipeDetail(ID); while (dr.Read()) { Comment item = new Comment(); if (dr["AUTHOR"] != DBNull.Value) { item.Author = (string)dr["AUTHOR"]; } if (dr["EMAIL"] != DBNull.Value) { item.Email = (string)dr["EMAIL"]; } if (dr["DATE"] != DBNull.Value) { item.Date = (DateTime)(dr["DATE"]); } if (dr["COMMENTS"] != DBNull.Value) { item.Comments = (string)dr["COMMENTS"]; } GetComment.Add(item); } dr.Close(); return GetComment; FetchData = null; }
public void Insert() { //Instantiate object Blogic myBL = new Blogic(); string strCookieName = ""; switch (WhatPageID) { case constant.intRecipe: strCookieName = "XDWorldRecipeRatingCookie"; //Cookie name for recipe user rating break; case constant.intArticle: strCookieName = "XDArticleRatingCookie"; //Cookie name for article user rating break; } //Create cookie HttpCookie RateCookie = new HttpCookie(strCookieName); RateCookie.Value = ID.ToString(); //Assign ID to cookie value RateCookie.Expires = DateTime.Now.AddDays(1); //Expire cookie in 1 day HttpContext.Current.Response.Cookies.Add(RateCookie); switch (WhatPageID) { case constant.intRecipe: //Insert recipe rating and redirect back to recipedetail.aspx myBL.AddRating(ID, RateVal); myBL = null; //Release allocated memory HttpContext.Current.Response.Redirect("recipedetail.aspx?id=" + ID); break; case constant.intArticle: //Insert article rating and redirect back to articledetail.aspx myBL.AddArticleRating(ID, RateVal); myBL = null; //Release allocated memory HttpContext.Current.Response.Redirect("articledetail.aspx?&aid=" + ID); break; } }
/// <summary> /// Return Recipe Category Data /// </summary> public static ExtendedCollection<Recipe> GetCategories() { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); ExtendedCollection<Recipe> GetCategory = new ExtendedCollection<Recipe>(); IDataReader dr = FetchData.AdminGetRecipeCategoryManager; while (dr.Read()) { Recipe item = new Recipe(); item.CatID = (int)dr["CAT_ID"]; if (dr["CAT_TYPE"] != DBNull.Value) { item.Category = (string)dr["CAT_TYPE"]; } if (dr["GROUPCAT"] != DBNull.Value) { item.Group = (string)dr["GROUPCAT"]; } if (dr["REC_COUNT"] != DBNull.Value) { item.RecordCount = (int)(dr["REC_COUNT"]); } GetCategory.Add(item); } dr.Close(); return GetCategory; FetchData = null; }
/// <summary> /// Return the recipe image /// </summary> public static string GetImage(int ID) { //Instantiate sql params object Blogic myBL = new Blogic(); string FileName; FileName = "../RecipeImageUpload/noimageavailable.gif"; IDataReader dr = myBL.GetRecipeImageFileNameForUpdate(ID); dr.Read(); if (dr["RecipeImage"] != DBNull.Value) { FileName = "../RecipeImageUpload/" + (string)dr["RecipeImage"]; } dr.Close(); myBL = null; return FileName; }
/// <summary> /// Perform Insert to Database /// </summary> /// <returns></returns> public override int Add() { return ActionSP.AdminAddNewArticleCategory(Category); ActionSP = null; }
/// <summary> /// Get article title, author, date, hits, rating and content from the DB matching the Article ID provided. /// </summary> public override void fillup() { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); //Instantiate object Utility Util = new Utility(); //Parameter 1 = we are dealing with the articledetail.aspx not the admin article update which is 2. IDataReader dr = FetchData.GetArticleDetail(ID, WhatPageID); dr.Read(); if (WhatPageID == constant.intArticleDetails) //Populate articledetail.aspx { try { if (dr["Title"] != DBNull.Value) { this._Title = (string)dr["Title"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["No_Rates"] != DBNull.Value) { this._NoRates = dr["No_Rates"].ToString(); } if (dr["HITS"] != DBNull.Value) { this._Hits = (int)dr["HITS"]; } if (dr["Rates"] != DBNull.Value) { this._Rating = dr["Rates"].ToString(); } if (dr["Content"] != DBNull.Value) { this._Content = (string)dr["Content"]; } if (dr["CAT_NAME"] != DBNull.Value) { this._Category = (string)dr["CAT_NAME"]; } if (dr["CAT_ID"] != DBNull.Value) { this._CatID = (int)dr["CAT_ID"]; } if (dr["Post_Date"] != DBNull.Value) { this._Date = (DateTime)(dr["Post_Date"]); } } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } else if (WhatPageID == constant.intArticleAdminUpdate) //Populate Admin/updatearticle.aspx { try { if (dr["Title"] != DBNull.Value) { this._Title = (string)dr["Title"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["CAT_NAME"] != DBNull.Value) { this._Category = (string)dr["CAT_NAME"]; } if (dr["Content"] != DBNull.Value) { this._Content = (string)dr["Content"]; } if (dr["Summary"] != DBNull.Value) { this._Summary = (string)dr["Summary"]; } if (dr["Keyword"] != DBNull.Value) { this._Keyword = (string)dr["Keyword"]; } if (dr["CAT_ID"] != DBNull.Value) { this._CatID = (int)dr["CAT_ID"]; } if (dr["Post_Date"] != DBNull.Value) { this._Date = (DateTime)(dr["Post_Date"]); } } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } else if (WhatPageID == constant.intArticleAdminPreview) //Populate Admin/articlepreview.aspx { try { if (dr["Title"] != DBNull.Value) { this._Title = (string)dr["Title"]; } if (dr["Content"] != DBNull.Value) { this._Content = (string)dr["Content"]; } } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } //Release allocated memory dr.Close(); dr = null; FetchData = null; Util = null; }
/// <summary> /// Perform Update /// </summary> /// <returns></returns> public override int Update() { return ActionSP.UpdateRecipeComments(ID, Author, Email, Comments); ActionSP = null; }
/// <summary> /// Perform Delete /// </summary> /// <returns></returns> public override int Delete() { return ActionSP.AdminDeleteRecipeComments(ID, RECID); ActionSP = null; }
/// <summary> /// Perform Insert to Database /// </summary> /// <returns></returns> public override int Add() { return ActionSP.AddComment(ID, Author, Email, Comments); ActionSP = null; }
/// <summary> /// Perform Update /// </summary> /// <returns></returns> public override int Update() { return ActionSP.UpdateArticle(ID, Title, Content, Author, CatID, Keyword, Summary); ActionSP = null; }
/// <summary> /// Get recipe name, author, date, hits, rating, ingredients, instructions and other field from the DB matching the Recipe ID provided. /// </summary> public override void fillup() { //Instantiate Action Stored Procedure object Blogic FetchData = new Blogic(); //Instantiate object Utility Util = new Utility(); /* The reason why we have to use a conditional statement is because we are dealing with 3 diffrent * stored procedures to return the data. Each sproc has its number of columns declared and diffrent where clauses. */ if (WhatPageID == constant.intRecipeDetails) //Populate Recipedetail.aspx database fields { try { IDataReader dr = FetchData.GetRecipeDetail(ID); dr.Read(); if (dr["Name"] != DBNull.Value) { this._RecipeName = (string)dr["Name"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["CAT_ID"] != DBNull.Value) { this._CatID = (int)dr["CAT_ID"]; } if (dr["NO_RATES"] != DBNull.Value) { this._NoRates = dr["NO_RATES"].ToString(); } if (dr["HITS"] != DBNull.Value) { this._Hits = (int)dr["HITS"]; } if (dr["Rates"] != DBNull.Value) { this._Rating = dr["Rates"].ToString(); } if (dr["Category"] != DBNull.Value) { this._Category = (string)dr["Category"]; } if (dr["Ingredients"] != DBNull.Value) { this._Ingredients = (string)dr["Ingredients"]; } if (dr["Instructions"] != DBNull.Value) { this._Instructions = (string)dr["Instructions"]; } if (dr["Date"] != DBNull.Value) { this._Date = (DateTime)(dr["Date"]); } if (dr["TOTAL_COMMENTS"] != DBNull.Value) { this._CountComments = (int)dr["TOTAL_COMMENTS"]; } if (dr["LINK_APPROVED"] != DBNull.Value) { this._Approved = (int)dr["LINK_APPROVED"]; } if (dr["RecipeImage"] != DBNull.Value) { this._RecipeImage = (string)dr["RecipeImage"]; } //Release allocated memory dr.Close(); dr = null; } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } else if (WhatPageID == constant.intRecipeAdminViewing) //Populate Admin/viewing.aspx database fields { try { IDataReader dr = FetchData.AdminRecipeApprovalReview(ID); dr.Read(); if (dr["Name"] != DBNull.Value) { this._RecipeName = (string)dr["Name"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["HITS"] != DBNull.Value) { this._Hits = (int)dr["HITS"]; } if (dr["Category"] != DBNull.Value) { this._Category = (string)dr["Category"]; } if (dr["Ingredients"] != DBNull.Value) { this._Ingredients = (string)dr["Ingredients"]; } if (dr["Instructions"] != DBNull.Value) { this._Instructions = (string)dr["Instructions"]; } if (dr["Date"] != DBNull.Value) { this._Date = (DateTime)(dr["Date"]); } if (dr["LINK_APPROVED"] != DBNull.Value) { this._Approved = (int)dr["LINK_APPROVED"]; } if (dr["HIT_DATE"] != DBNull.Value) { this._HitDate = (DateTime)dr["HIT_DATE"]; } //Release allocated memory dr.Close(); dr = null; } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } else if (WhatPageID == constant.intRecipeAdminEditing) //Populate Admin/editing.aspx database fields { try { IDataReader dr = FetchData.GetRecipeDetailForUpdate(ID); dr.Read(); if (dr["Name"] != DBNull.Value) { this._RecipeName = (string)dr["Name"]; } if (dr["Author"] != DBNull.Value) { this._Author = (string)dr["Author"]; } if (dr["HITS"] != DBNull.Value) { this._Hits = (int)dr["HITS"]; } if (dr["Ingredients"] != DBNull.Value) { this._Ingredients = (string)dr["Ingredients"]; } if (dr["Instructions"] != DBNull.Value) { this._Instructions = (string)dr["Instructions"]; } //Release allocated memory dr.Close(); dr = null; } catch { //Redirect to page not found. //1 = pagenotfound.aspx Util.PageRedirect(1); } return; } //Release allocated memory FetchData = null; Util = null; }
/// <summary> /// Perform Delete /// </summary> /// <returns></returns> public override int Delete() { return ActionSP.AdminRecipeManagerDelete(ID); ActionSP = null; }
/// <summary> /// Perform Insert to Database /// </summary> /// <returns></returns> public override int Add() { return ActionSP.AddRecipe(RecipeName, Author, CatID, Category, Ingredients, Instructions, RecipeImage); ActionSP = null; }
/// <summary> /// Perform Delete /// </summary> /// <returns></returns> public override int Delete() { return ActionSP.AdminDeleteArticleCategory(CatID); ActionSP = null; }
/// <summary> /// Perform Update /// </summary> /// <returns></returns> public override int Update() { return ActionSP.UpdateArticleCategory(CatID, Category); ActionSP = null; }
/// <summary> /// Perform Insert to Database /// </summary> /// <returns></returns> public override int Add() { return ActionSP.AddArticle(Title, Content, Author, CatID, Keyword, Summary); ActionSP = null; }
/// <summary> /// Perform Update /// </summary> /// <returns></returns> public override int Update() { return ActionSP.UpdateRecipe(ID, RecipeName, Author, CatID, Ingredients, Instructions, Hits, RecipeImage); ActionSP = null; }
/// <summary> /// Perform Insert to Database /// </summary> /// <returns></returns> public override int Add() { return ActionSP.AdminAddNewRecipeCategory(Category, CatGroupID); ActionSP = null; }