Esempio n. 1
0
        public void Test_ActivityReply()
        {
            // Ensures that we can serialize and deserialize activity reply messages.

            ActivityReply message;

            using (var stream = new MemoryStream())
            {
                // Empty message.

                message = new ActivityReply();

                stream.SetLength(0);
                stream.Write(message.SerializeAsBytes(ignoreTypeCode: true));
                stream.Seek(0, SeekOrigin.Begin);

                message = ProxyMessage.Deserialize <ActivityReply>(stream, ignoreTypeCode: true);
                Assert.NotNull(message);
                Assert.Equal(0, message.RequestId);
                Assert.Null(message.Error);
                Assert.Equal(0, message.ActivityContextId);

                // Round-trip

                message.ClientId          = 444;
                message.RequestId         = 555;
                message.Error             = new CadenceError("MyError");
                message.ActivityContextId = 666;

                Assert.Equal(444, message.ClientId);
                Assert.Equal(555, message.RequestId);
                Assert.Equal("MyError", message.Error.String);
                Assert.Equal(666, message.ActivityContextId);

                stream.SetLength(0);
                stream.Write(message.SerializeAsBytes(ignoreTypeCode: true));
                stream.Seek(0, SeekOrigin.Begin);

                message = ProxyMessage.Deserialize <ActivityReply>(stream, ignoreTypeCode: true);
                Assert.NotNull(message);
                Assert.Equal(444, message.ClientId);
                Assert.Equal(555, message.RequestId);
                Assert.Equal("MyError", message.Error.String);
                Assert.Equal(666, message.ActivityContextId);

                // Clone()

                message = (ActivityReply)message.Clone();
                Assert.NotNull(message);
                Assert.Equal(444, message.ClientId);
                Assert.Equal(555, message.RequestId);
                Assert.Equal("MyError", message.Error.String);
                Assert.Equal(666, message.ActivityContextId);
            }
        }
Esempio n. 2
0
        public JsonResult ReplyActivity(int activityId, string content)
        {
            var acireply = new ActivityReply();

            acireply.ActivityId   = activityId;
            acireply.ReplyContent = content;
            acireply.ReplyTime    = DateTime.Now;
            acireply.UserId       = CurrentUser.UserId;
            activityService.AddActivityReply(acireply);
            //加冗余
            return(Json(new { result = 1, replyTime = acireply.ReplyTime.ToString("yyyy-MM-dd HH:mm") }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public async Task ToggleActivityReplyLikeAsync(ActivityReply activityReply, int activityPosition)
        {
            var toggleResp = await AniListService.ToggleLike(activityReply.Id, LikeableType.ActivityReply, default);

            toggleResp.Switch((IAniListError error) =>
            {
                View.DisplaySnackbarMessage("Error occurred while toggling like", Snackbar.LengthLong);
            })
            .Switch(userLikes =>
            {
                activityReply.Likes = userLikes;
            });
        }
Esempio n. 4
0
        public async Task <bool> DeleteActivityReplyAsync(ActivityReply activityReply,
                                                          int activityPosition)
        {
            var editResp = await AniListService.DeleteActivityReply(activityReply.Id, default);

            return(editResp.Match((IAniListError error) =>
            {
                View.DisplaySnackbarMessage("Error occurred while deleting reply", Snackbar.LengthLong);

                return false;
            })
                   .Match(deletedResponse => deletedResponse.Deleted));
        }
Esempio n. 5
0
        public async Task EditActivityReplyAsync(ActivityReply activityReply, int activityPosition, string updateText)
        {
            var editResp = await AniListService.SaveActivityReply(activityReply.Id, updateText, default);

            editResp.Switch((IAniListError error) =>
            {
                View.DisplaySnackbarMessage("Error occurred while updating reply", Snackbar.LengthLong);
            })
            .Switch(retReply =>
            {
                activityReply.Text  = retReply.Text;
                activityReply.Likes = retReply.Likes;
            });
        }
Esempio n. 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ActivityReply model)
 {
     return(_dataAccess.UpdateEntity(model) > 0);
 }
Esempio n. 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(ActivityReply model)
 {
     return(_dataAccess.AddEntity(model));
 }
Esempio n. 8
0
 /// <summary>
 /// 添加动态的回复信息(冗余信息一并更新)
 /// </summary>
 /// <param name="reply"></param>
 /// <returns></returns>
 public int AddActivityReply(ActivityReply reply)
 {
     _dataAccess.AddEntity(reply);
     return(_dataAccess.UpdateField("Int_UserActivity", "ReplyCount", "ReplyCount+1", "ActivityId=" + reply.ActivityId));
 }