Esempio n. 1
0
        /// <summary>
        /// 處理按讚資料
        /// </summary>
        /// <param name="memberInfo">按讚者資訊</param>
        /// <param name="likeOuterKey">主題討論代碼/留言代碼</param>
        /// <param name="IsMsg">是否為留言</param>
        /// <returns></returns>
        private LikeLog LikeDbProxy(Member memberInfo, Guid likeOuterKey, bool IsMsg)
        {
            var db     = _uow.DbContext;
            var result = new Infrastructure.Entity.LikeLog();

            //判斷是否曾經按過讚
            result = db.LikeLog.FirstOrDefault(t => t.OuterKey == likeOuterKey && t.MemberId == memberInfo.Id);
            if (result != null)
            {
                result.Deleted    = TimeData.Create(null);
                result.DeleteUser = null;
            }
            //新增按讚資訊
            else
            {
                result = new Infrastructure.Entity.LikeLog()
                {
                    Created    = TimeData.Create(DateTime.UtcNow),
                    CreateUser = memberInfo.Id,
                    Deleted    = TimeData.Create(null),
                    Updated    = TimeData.Create(null),
                    MemberId   = memberInfo.Id,
                    IsMsg      = IsMsg,
                    OuterKey   = likeOuterKey
                };
                db.LikeLog.Add(result);
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 處理取消讚資料
        /// </summary>
        /// <param name="memberInfo">按讚者資訊</param>
        /// <param name="likeOuterKey">主題討論代碼/留言代碼</param>
        /// <returns></returns>
        private LikeLog UnLikeDbProxy(Member memberInfo, Guid likeOuterKey)
        {
            var db     = _uow.DbContext;
            var result = new Infrastructure.Entity.LikeLog();

            //判斷是否曾經按過讚
            result = db.LikeLog.FirstOrDefault(t => t.OuterKey == likeOuterKey && t.MemberId == memberInfo.Id);
            if (result != null)
            {
                result.Deleted    = TimeData.Create(DateTime.UtcNow);
                result.DeleteUser = memberInfo.Id;
            }
            return(result);
        }