Ejemplo n.º 1
0
        /// <summary>
        /// 添加一个点赞记录
        /// </summary>
        protected virtual void AddGiveLike(Guid userId)
        {
            // 避免重复点赞
            if (GiveLikes.Exists(x => x.UserId == userId))
            {
                return;
            }

            var record = new GiveLike(userId, Id);

            GiveLikes.Add(record);

            GiveLikeNumber += 1;
        }
Ejemplo n.º 2
0
        public async Task <GiveLike> CreateAsync(GiveLike giveLike, Comment comment, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (giveLike == null)
            {
                throw new ArgumentNullException(nameof(giveLike));
            }
            Context.Add(giveLike);
            Context.Attach(comment);
            var entry = Context.Entry(comment);

            entry.Property(x => x.LikeNum).IsModified = true;
            await Context.SaveChangesAsync(cancellationToken);

            return(giveLike);
        }
Ejemplo n.º 3
0
 public void LogIn_GiveLike()
 {
     try
     {
         var driver       = SetUp();
         var loginAccount = new LogIn(driver, new WebDriverWait(driver, TimeSpan.FromSeconds(10)));
         loginAccount.LoginAccount(driver);
         var like = new GiveLike(driver, new WebDriverWait(driver, TimeSpan.FromSeconds(10)));
         like.Like(driver);
         driver.Quit();
     }
     catch (Exception e)
     {
         TestContext.Error.WriteLine($"{e.ToString()}");
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 点赞
        /// </summary>
        /// <param name="userid">创建者</param>
        /// <param name="id">评论ID</param>
        /// <param name="cancellationToken">验证</param>
        /// <returns></returns>
        public virtual async Task CreateGiveLikeAsync(string userid, string id, CancellationToken cancellationToken = default(CancellationToken))
        {
            var comment = await _icommentStore.GetAsync(a => a.Where(b => b.Id == id), cancellationToken);

            if (comment == null)
            {
                return;
            }
            var like = new GiveLike();

            like.Id         = id;
            like.CreateTime = DateTime.Now;
            like.CustomerId = userid;
            comment.LikeNum++;

            await _igiveLikeStore.CreateAsync(like, comment, cancellationToken);
        }
Ejemplo n.º 5
0
        public async Task DeleteAsync(GiveLike giveLike, Comment comment, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (giveLike == null)
            {
                throw new ArgumentNullException(nameof(giveLike));
            }
            Context.Remove(giveLike);
            Context.Attach(comment);
            var entry = Context.Entry(comment);

            entry.Property(x => x.LikeNum).IsModified = true;
            try
            {
                await Context.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }