示例#1
0
        public static async Task <bool> ChangeReadList(int readListId, BookListChangeType changeType,
                                                       int?alteredId = null, string alteredText = null)
        {
            if (Util.MainElem.CurrentPage == typeof(BillboardPage) && Storage.IsAdmin)
            {
                return(await NetworkAdmin.ChangeBillboard(readListId, changeType, alteredId, alteredText));
            }

            var change = new ChangeObject("ChangeReadList")
            {
                ReadListId    = readListId,
                ChangeType    = (int)changeType,
                AlteredBookId = alteredId,
                AlteredText   = alteredText
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#2
0
        public static async Task <bool> CancelTransaction(int bookId)
        {
            var change = new ChangeObject("CancelTransaction")
            {
                BookId = bookId,
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#3
0
        internal static async Task <bool> FollowReadList(int readListId, bool isFollowAction)
        {
            var change = new ChangeObject("FollowReadList")
            {
                ReadListId     = readListId,
                IsFollowAction = isFollowAction,
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#4
0
        public static async Task <bool> CreateReadList(string title, string desc)
        {
            var change = new ChangeObject("CreateReadList")
            {
                Description = desc,
                Title       = title
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#5
0
        public static async Task <bool> ChangeWishlist(int bookId, bool isAddAction)
        {
            var change = new ChangeObject("ChangeWishlist")
            {
                BookId      = bookId,
                IsAddAction = isAddAction
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#6
0
        public static async Task <bool> CreateDanmu(string content, int bookId, uint pageNum)
        {
            var change = new ChangeObject("CreateDanmu")
            {
                Content = content,
                BookId  = bookId,
                PageNum = (int)pageNum
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#7
0
        public static async Task <bool> SignUp(string userName, string email, string password)
        {
            var change = new ChangeObject("SignUp")
            {
                UserName        = userName,
                Email           = email,
                EncodedPassword = password
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#8
0
        public static async Task <bool> CreateReview(int bookId, int rating, string title, string content)
        {
            var change = new ChangeObject("CreateReview")
            {
                BookId  = bookId,
                Rating  = rating,
                Title   = title,
                Content = content
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#9
0
        public static async Task <bool> ChangeDanmu(int danmuId, bool isDeleteAction,
                                                    string newContent = null)
        {
            var change = new ChangeObject("ChangeDanmu")
            {
                DanmuId        = danmuId,
                IsDeleteAction = isDeleteAction,
                NewContent     = newContent
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#10
0
        public static async Task <bool> ChangeReview(int reviewId, bool isDelete, int rating, string title, string content)
        {
            var change = new ChangeObject("ChangeReview")
            {
                ReviewId       = reviewId,
                NewTitle       = title,
                NewContent     = content,
                NewRating      = rating,
                IsDeleteAction = isDelete
            };

            if (Storage.Test)
            {
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            return(recv.Success);
        }
示例#11
0
        public static async Task <bool> Logout()
        {
            var change = new ChangeObject("Logout")
            {
            };

            if (Storage.Test)
            {
                Storage.UserId  = -1;
                Storage.IsAdmin = false;
                return(true);
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            if (recv.Success)
            {
                Storage.UserId  = -1;
                Storage.IsAdmin = false;
            }
            return(recv.Success);
        }
示例#12
0
        public static async Task <string> BuyBook(int bookId)
        {
            var change = new ChangeObject("BuyBook")
            {
                BookId = bookId
            };

            if (Storage.Test)
            {
                return("https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf");
            }

            var recv = await Connection.SendAndReceive.GlobalLock(change);

            if (recv.Success && recv.URL != null)
            {
                return(recv.URL);
            }
            else
            {
                return(null);
            }
        }