public async Task Post(string shareId) { var shareService = this.UseShareService().GetShareService(); var share = await shareService.VoteShare(UserSessionData.UserId, shareId); var updateMsg = new ShareThingUpdatedMessage() { ShareId = share.Id.ToString(), Time = DateTime.UtcNow }; Startup.ServicesProvider.GetBahamutPubSubService().PublishShareUpdatedMessages(share.UserId.ToString(), updateMsg); }
public static void PublishShareUpdatedMessages(this BahamutPubSubService service, string userId, ShareThingUpdatedMessage updateMsg) { var cacheModel = new BahamutCacheModel { AppUniqueId = Startup.Appname, CacheDateTime = DateTime.UtcNow, UniqueId = userId, DeserializableString = JsonConvert.SerializeObject(updateMsg), Type = ShareThingUpdatedMessage.NotifyType }; Startup.ServicesProvider.GetBahamutCacheService().PushCacheModelToList(cacheModel); var pbModel = new BahamutPublishModel { NotifyType = "Toronto", ToUser = userId, CustomCmd = "UsrNewSTMsg", NotifyInfo = JsonConvert.SerializeObject(new { LocKey = "NEW_SHARE_NOTIFICATION" }) }; Startup.ServicesProvider.GetBahamutPubSubService().PublishBahamutUserNotifyMessage(PublishConstants.NotifyId, pbModel); }
public static void PublishShareMessages(this BahamutPubSubService service, List<ShareThingMail> mails) { foreach (var m in mails) { var smsg = new ShareThingUpdatedMessage() { ShareId = m.ShareId.ToString(), Time = DateTime.UtcNow }; PublishShareUpdatedMessages(service, m.ToSharelinker.ToString(), smsg); } }