public void Dictionary_Call_ReturnTranslationByPath(string path, string defaultValue, string translate)
        {
            //Arrange
            this.dictionaryPhraseRepository.Get(path, defaultValue).Returns(translate);

            //Act
            var result = SitecoreExtensions.Dictionary(null, path, defaultValue);

            //Assert
            result.Should().Be(translate);
        }
示例#2
0
        private bool isDelayPost(string userIP)
        {
            bool isDelay = false;

            using (var db = Factory.DbEntities)
            {
                try
                {
                    SqlParameter paramMaxComment = new SqlParameter("@maxcomment", SitecoreExtensions.Dictionary(sitecoreHelper, "/Feature/Maybank Blog/Max Comment", "3"));
                    SqlParameter paramDelayTime  = new SqlParameter("@delayTime", SitecoreExtensions.Dictionary(sitecoreHelper, "/Feature/Maybank Blog/Delay Time", "00:03"));
                    SqlParameter paramUserIP     = new SqlParameter("@userIP", userIP);
                    isDelay = Convert.ToBoolean(db.Database.SqlQuery <int>("exec sp_DELAY_BLOG_POST @maxcomment, @delayTime, @userIP", paramMaxComment, paramDelayTime, paramUserIP).FirstOrDefault());
                }
                catch (Exception ex)
                {
                    ErrorWebservice(ex.Message.ToString());
                }
                return(isDelay);
            }
        }
示例#3
0
        public ActionResult PostComment(FormCollection formData)
        {
            Sitecore.Data.Items.Item blogItem = Sitecore.Context.Database.GetItem(Sitecore.Feature.Library.Helper.Variables.MaybankBlogItem);
            bool IsUseCaptcha = ((CheckboxField)blogItem.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields.IsUseCaptcha]).Checked;

            string _userIP = string.Empty;

            GetIpValue(out _userIP);


            BlogComment blogComment = new BlogComment()
            {
                ID              = Guid.NewGuid(),
                PageID          = Request.Form["pageId"],
                PageDisplayName = Request.Form["pageName"],
                Username        = Request.Form["username"],
                Email           = Request.Form["email"],
                Comment         = Request.Form["blogcomment"],
                CommentDate     = DateTime.Now,
                UserIP          = _userIP,
                isApproved      = false,
                ApprovedDate    = null,
                isDelete        = false,
                DeletedDate     = null
            };

            if (IsUseCaptcha && !IsReCaptchValid())
            {
                return(ErrorWebservice(SitecoreExtensions.Dictionary(sitecoreHelper, "/Feature/Maybank Blog/Invalid Captcha Error Message", "Google reCaptcha validation failed")));
            }

            if (!isDelayPost(_userIP))
            {
                this.Repository.PostComment(blogComment);
            }
            else
            {
                return(ErrorWebservice(SitecoreExtensions.Dictionary(sitecoreHelper, "/Feature/Maybank Blog/Excessive Request", "Excessive Request Attempts Detected")));
            }
            return(Json(SuccessResponse(), JsonRequestBehavior.AllowGet));
        }
示例#4
0
 public ActionResult SessionExpired()
 {
     return(ErrorWebservice(SitecoreExtensions.Dictionary(sitecoreHelper, SESSION_EXPIRED_DICTIONARY_PATH, "Sesi Anda telah habis, silahkan refresh halaman Anda!")));
 }