예제 #1
0
        public void SetBookStat(Guid userId, string bookUrl, UserStatStateEnum state, string actionId = null)
        {
            var socialUserId = GetSocialUserId(userId);

            if (string.IsNullOrEmpty(socialUserId) || state == UserStatStateEnum.None)
            {
                return;
            }

            if (!string.IsNullOrEmpty(actionId))
            {
                DeleteAction(actionId);
            }

            Task.Factory.StartNew(() =>
            {
                var postParams = new JsonObject
                {
                    { "book", GetNormalizedUrl(bookUrl) },
                    { "progress:timestamp", string.Format("{0:s}{0:zzz}", DateTime.Now) },
                    { "progress:percent_complete", state == UserStatStateEnum.IsReading ? 0.0 : 100 }
                };

                var client = new FacebookClient(AccessToken);
                client.Post(string.Format("{0}/books.{1}", socialUserId, BookStatToPostfix(state)), postParams);
            });
        }
예제 #2
0
 private string BookStatToPostfix(UserStatStateEnum state)
 {
     if (state == UserStatStateEnum.WantsToRead)
     {
         return("wants_to_read");
     }
     return("reads");
 }
예제 #3
0
        public PartialViewResult SetUserStatToBook(Guid bookId, UserStatStateEnum state)
        {
            BookModel model = new BookModel
            {
                Id        = bookId,
                UserStats = DataService.SetUserStatToBook(bookId, (Guid)User.UserId, state)
            };

            _socialService.SetBookStat((Guid)User.UserId,
                                       Request.Url.GetRootUrl() + Url.Action("Book", "Catalogue", new { id = bookId }),
                                       state);
            return(PartialView("~/Views/Partial/UserStats.cshtml", model));
        }
예제 #4
0
 public PartialViewResult MyBooksItems(UserStatStateEnum state, int lastRowIndex = 0, Guid? genreId = null)
 {
     MyBooksModel model = DataService.GetMyBooks((Guid)User.UserId, state, lastRowIndex, genreId);
     return PartialView(model);
 }
예제 #5
0
 public PartialViewResult SetUserStatToBook(Guid bookId, UserStatStateEnum state)
 {
     BookModel model = new BookModel
         {
             Id = bookId,
             UserStats = DataService.SetUserStatToBook(bookId, (Guid)User.UserId, state)
         };
     _socialService.SetBookStat((Guid)User.UserId,
                                Request.Url.GetRootUrl() + Url.Action("Book", "Catalogue", new { id = bookId }),
                                state);
     return PartialView("~/Views/Partial/UserStats.cshtml", model);
 }
예제 #6
0
        public PartialViewResult MyBooksItems(UserStatStateEnum state, int lastRowIndex = 0, Guid?genreId = null)
        {
            MyBooksModel model = DataService.GetMyBooks((Guid)User.UserId, state, lastRowIndex, genreId);

            return(PartialView(model));
        }
예제 #7
0
        public void SetBookStat(Guid userId, string bookUrl, UserStatStateEnum state, string actionId = null)
        {
            var socialUserId = GetSocialUserId(userId);
            if (string.IsNullOrEmpty(socialUserId) || state == UserStatStateEnum.None)
                return;

            if (!string.IsNullOrEmpty(actionId))
                DeleteAction(actionId);

            Task.Factory.StartNew(() =>
            {
                var postParams = new JsonObject
                {
                    {"book", GetNormalizedUrl(bookUrl)},
                    {"progress:timestamp", string.Format("{0:s}{0:zzz}", DateTime.Now)},
                    {"progress:percent_complete", state == UserStatStateEnum.IsReading ? 0.0 : 100}
                };

                var client = new FacebookClient(AccessToken);
                client.Post(string.Format("{0}/books.{1}", socialUserId, BookStatToPostfix(state)), postParams);
            });
        }
예제 #8
0
 private string BookStatToPostfix(UserStatStateEnum state)
 {
     if (state == UserStatStateEnum.WantsToRead)
         return "wants_to_read";
     return "reads";
 }