Exemple #1
0
        /// <summary>
        /// Adds the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="opertionUser">操作者信息</param>
        /// <returns>Result.</returns>
        public static Result Add(Dictionary <string, object> dicwhere, OpertionUser opertionUser)
        {
            try
            {
                var memid   = dicwhere[nameof(ArticlePraise.MemberId)].ToString();
                var blognum = dicwhere[nameof(ArticlePraise.BlogNum)].ToString();
                var ap      = ArticlePraiseLogic.GetModelByWhere(new Dictionary <string, object>()
                {
                    { nameof(ArticlePraise.MemberId), memid },
                    { nameof(ArticlePraise.BlogNum), blognum }
                });
                if (ap != null || ap?.KID > 0)
                {
                    return(new Result()
                    {
                        IsSucceed = false, Message = "该文章你已点赞"
                    });
                }

                var ret = ArticlePraiseRepository.Instance.Add <ArticlePraise>(dicwhere);
                Task.Run(() =>
                {
                    if (ret > 0)
                    {
                        ArticlePraiseRepository.UpdateBloginfo(blognum);
                    }
                });

                DbLog.WriteDbLog(nameof(ArticlePraise), "添加记录", ret, dicwhere.ToJsonString(), opertionUser, OperLogType.添加);

                return(new Result()
                {
                    IsSucceed = ret > 0, Message = ret.ToString()
                });
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex, "ArticlePraiseLogic/add");
                return(new Result()
                {
                    IsSucceed = false, Message = "系统错误" + ex.Message
                });
            }
        }
Exemple #2
0
        /// <summary>
        /// Edits the specified dicwhere.
        /// </summary>
        /// <param name="dicwhere">修改条件</param>
        /// <param name="kID">当前数据主键KID</param>
        /// <param name="opertionUser">操作者信息</param>
        /// <returns>Result.</returns>
        public static Result Update(Dictionary <string, object> dicwhere, int kID, OpertionUser opertionUser)
        {
            var ret = ArticlePraiseRepository.Instance.UpdateByKey <ArticlePraise>(dicwhere, kID);

            Task.Run(() =>
            {
                if (ret > 0)
                {
                    var model = ArticlePraiseRepository.Instance.GetEntityByKey <ArticlePraise>(kID);

                    ArticlePraiseRepository.UpdateBloginfo(model.BlogNum);
                }
            });


            DbLog.WriteDbLog(nameof(ArticlePraise), "修改记录", kID, dicwhere, OperLogType.编辑, opertionUser);

            return(new Result()
            {
                IsSucceed = ret > 0
            });
        }