Пример #1
0
        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;
            }
        }