Exemplo n.º 1
0
        public HttpResponseMessage VoteDown(int itemId)
        {
            var floodControl = new FloodControl(this.Request.FindModuleId(),
                                                this.Request.FindTabId(),
                                                this.Request.GetIPAddress(),
                                                this.UserInfo);

            if (floodControl.AllowVote(itemId))
            {
                var currentDownVote = _repository
                                      .VoteDown(itemId);

                Log.DebugFormat("Vote down recorded, IP:{0}, itemId:{1}",
                                this.Request.GetIPAddress(),
                                itemId);

                return(Request.CreateResponse(new
                {
                    success = true,
                    data = new { voteDown = currentDownVote }
                }));
            }
            else
            {
                Log.WarnFormat("Flood control block the vote. The IP:{0} has already voted on this item:{1} in the time limit window",
                               this.Request.GetIPAddress(),
                               itemId);

                return(Request.CreateResponse(new
                {
                    success = false
                }));
            }
        }