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); }); }
private string BookStatToPostfix(UserStatStateEnum state) { if (state == UserStatStateEnum.WantsToRead) { return("wants_to_read"); } return("reads"); }
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)); }
public PartialViewResult MyBooksItems(UserStatStateEnum state, int lastRowIndex = 0, Guid? genreId = null) { MyBooksModel model = DataService.GetMyBooks((Guid)User.UserId, state, lastRowIndex, genreId); return PartialView(model); }
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); }
public PartialViewResult MyBooksItems(UserStatStateEnum state, int lastRowIndex = 0, Guid?genreId = null) { MyBooksModel model = DataService.GetMyBooks((Guid)User.UserId, state, lastRowIndex, genreId); return(PartialView(model)); }
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); }); }
private string BookStatToPostfix(UserStatStateEnum state) { if (state == UserStatStateEnum.WantsToRead) return "wants_to_read"; return "reads"; }