Esempio n. 1
0
        /// <summary>
        /// 根据ID删除数据
        /// </summary>
        /// <param name="t">HuobiProject.Models</param>
        /// <returns>
        /// Success:T
        /// Failed:F
        /// </returns>
        bool ICURD <THelpful> .Delete(THelpful t)
        {
            THelpful hp = m_helpful.Retrieve(t);

            m_db.THelpful.Remove(hp);

            return(m_db.SaveChanges() > 0);
        }
Esempio n. 2
0
        /// <summary>
        /// 根据ID更新数据
        /// </summary>
        /// <param name="t">HuobiProject.Models</param>
        /// <returns>
        /// True:成功
        /// False:失败
        /// </returns>
        bool ICURD <THelpful> .Update(THelpful t)
        {
            THelpful hp = m_helpful.Retrieve(t);

            hp.Helpful = t.Helpful;
            hp.Ip      = t.Ip;

            return(m_db.SaveChanges() > 0);
        }
Esempio n. 3
0
        /// <summary>
        /// 增加数据
        /// </summary>
        /// <param name="t">HuobiProject.Models</param>
        /// <returns>
        /// True:成功
        /// False:失败
        /// </returns>
        bool ICURD <THelpful> .Create(THelpful t)
        {
            Random rand = new Random((int)Tools.Ticks());
            string id   = Tools.Ticks() + "" + rand.Next(1000, 10000);

            t.HelpfulId  = id;
            t.CreateTime = DateTime.Now;
            m_db.THelpful.Add(t);
            return(m_db.SaveChanges() > 0);
        }
Esempio n. 4
0
        public ActionResult <Result> Helpful([FromRoute] string articleLangId, [FromRoute] short helpful)
        {
            THelpful help = new THelpful()
            {
                Ip            = HttpContext.Request.Headers["X-Forwarded-For"].ToString(),
                ArticleLangId = articleLangId,
                Helpful       = helpful
            };

            if (helpfulServer.RetrieveByIp(articleLangId, help.Ip) != null)
            {
                throw new ResultException("不能重复评价此文章");
            }

            helpfulServer.CommitHelpful(help);
            return(new Result(200, "成功"));
        }
Esempio n. 5
0
 /// <summary>
 /// 根据文章Id设置文章是否有帮助
 /// </summary>
 /// <param name="helpful">是否有帮助</param>
 void IHelpful.CommitHelpful(THelpful helpful)
 {
     m_helpful.Create(helpful);
 }
Esempio n. 6
0
 /// <summary>
 /// 根据ID获取数据
 /// </summary>
 /// <param name="t">HuobiProject.Models</param>
 /// <returns>
 /// Success:T
 /// Failed:NULL
 /// </returns>
 THelpful ICURD <THelpful> .Retrieve(THelpful t)
 {
     return(m_db.THelpful.Find(t.HelpfulId));
 }
Esempio n. 7
0
        public ActionResult <Result> ClientHelpfulInfo([FromRoute] string articleLangId)
        {
            THelpful th = helpfulServer.RetrieveByIp(articleLangId, HttpContext.Request.Headers["X-Forwarded-For"].ToString());

            return(new Result(200, "成功", th == null ? 0 : (th.Helpful == 0 ? -1 : 1)));
        }