public ActionResult AddStoreFollow(int ID) { if (User.Identity.IsAuthenticated == false) { return(Json("You must login to Follow", JsonRequestBehavior.AllowGet)); } UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name); Follow temp = new Follow(); temp.UserId = user.UserId; temp.StoreId = ID; if (Follow_Logic.AddNewFollow(temp)) { Store store = db.Stores.Find(ID); ++store.TotalFollowers; db.Entry(store).State = EntityState.Modified; db.SaveChanges(); // Publish Message Message_Logic.PublishMessage(WebSecurity.CurrentUserId, Constant.PRONOUN_TYPE_USER, ID, Constant.PRONOUN_TYPE_STORE, Constant.MESSAGE_TYPE_FOLLOW); return(Json("true", JsonRequestBehavior.AllowGet)); } return(Json("false", JsonRequestBehavior.AllowGet)); }
public ActionResult AddUserFollow(int ID) { if (User.Identity.IsAuthenticated == false) { return(Json("You must login to Like", JsonRequestBehavior.AllowGet)); } Follow temp = new Follow(); temp.UserId = WebSecurity.CurrentUserId; temp.FollowedUserId = ID; if (Follow_Logic.AddNewFollow(temp)) { // Publish Message Message_Logic.PublishMessage(WebSecurity.CurrentUserId, Constant.PRONOUN_TYPE_USER, ID, Constant.PRONOUN_TYPE_USER, Constant.MESSAGE_TYPE_FOLLOW); return(Json("true", JsonRequestBehavior.AllowGet)); } return(Json("false", JsonRequestBehavior.AllowGet)); }
public ActionResult PostComment(Comment cmt) { if (User.Identity.IsAuthenticated == false) { return(Json("You must login to comment")); } cmt.CreateDate = DateTime.Now; cmt.UserId = WebSecurity.CurrentUserId; // publish message to subscribers UserProfile productOwner = db.Products.Find(cmt.ProductId).Store.Owner; bool pubResult = Message_Logic.PublishMessage( productOwner.UserId, Constant.PRONOUN_TYPE_USER, cmt.ProductId.HasValue ? cmt.ProductId.Value : 1, Constant.PRONOUN_TYPE_PRODUCT, Constant.MESSAGE_TYPE_COMMENT); if (Comment_Logic.AddNewComment(cmt) > 0) { return(Json("true")); } return(Json("Add comment error")); }
public ActionResult GetNewsFeed(int LastMessageId = 0) { List <MessageJson> messages = Message_Logic.GetNewsFeed(WebSecurity.CurrentUserId, LastMessageId); return(Json(messages, JsonRequestBehavior.AllowGet)); }