Example #1
0
    public string Handler_AddEditContentRating()
    {
        StringBuilder sbRet = new StringBuilder();
            ContentAPI apiContent = new ContentAPI();
            int iRating = 0;
            long iContent = 0;
            int iret = 0;
            bool bapproved = true;
            string sReview = "";
            string skey = "";
            try
            {
                string visitorid;
                // Check and see if the cookie has been set by the user
                if (Page.Request.Cookies["ekContentRatingID"] == null && ! Page.IsPostBack)
                {
                    visitorid = (string) (System.Guid.NewGuid().ToString().Replace("-", ""));
                    Page.Response.Cookies.Add(new System.Web.HttpCookie("ekContentRatingID", visitorid));
                    Page.Response.Cookies["ekContentRatingID"].Expires = DateTime.MaxValue;
                }
                else
                {
                    try
                    {
                        visitorid = Page.Request.Cookies["ekContentRatingID"].Value;
                    }
                    catch (Exception)
                    {
                        visitorid = string.Empty;
                    }
                }
                if (Request.QueryString["review"] != "")
                {
                    sReview = EkFunctions.HtmlEncode(Request.QueryString["review"]);
                }
                if (Request.QueryString["key"] != "")
                {
                    skey = EkFunctions.HtmlEncode(Request.QueryString["key"]);
                }
                iRating = Convert.ToInt32(Request.QueryString["rating"]);
                iContent = Convert.ToInt64(Request.QueryString["contentid"]);

                if ((Request.QueryString["LangType"] != null)&& Request.QueryString["LangType"] != "")
                {
                    apiContent.ContentLanguage = Convert.ToInt32(Page.Request.QueryString["LangType"]);
                }
                else
                {
                    System.Web.HttpCookie ecmCookie = Ektron.Cms.CommonApi.GetEcmCookie();
                    apiContent.ContentLanguage = Convert.ToInt32(ecmCookie["SiteLanguage"].ToString());
                }

                bapproved = Convert.ToBoolean(Request.QueryString["approved"]);
                if (bapproved == false && sReview == "")
                {
                    bapproved = true; //if there is no review text, it goes live auto.
                }
                iret = (Int32)apiContent.AddEditContentRating(iContent, visitorid, iRating, bapproved, sReview);
                sReview = HttpUtility.UrlDecode(sReview);

                sbRet.Append("  <method>AddEditRating</method>").Append(Environment.NewLine);
                sbRet.Append("  <result>").Append(iRating).Append("</result>").Append(Environment.NewLine);
                sbRet.Append("  <key>").Append(skey).Append("</key>").Append(Environment.NewLine);
                return sbRet.ToString();
            }
            catch (Exception)
            {

            }

            return sbRet.ToString();
    }