Inheritance: IMessage
Example #1
0
        public Guid Post(Guid accountId, string content)
        {
            Guid messageId = Guid.NewGuid();
            Blob<Message> bMessage = blobFactory.MMessage(messageId);

            try
            {
                IAccountInfo accountInfo = blobFactory.AInfo(accountId).GetIfExists(new AccountNotFound());
                Guid personnalListId = blobFactory.LPersonnalList(accountId).GetIfExists(new AccountNotFound());
                Message message = new Message(messageId, accountId, accountInfo.Name, "", DateTime.Now, content);
                MsgSetBlobPack bPersonnalListMsgs = blobFactory.MListMessages(personnalListId);

                // Save the message
                bMessage.Set(message);
                if (!bPersonnalListMsgs.AddMessage(message))
                    throw new AccountNotFound();

                // Add in listMsg -- if a list is added during the foreach, then the message will be added by the addition of the list
                foreach (Guid listId in blobFactory.LFollowedByAll(accountId).GetIfExists(new AccountNotFound()))
                {
                    try { blobFactory.MListMessages(listId).AddMessage(message); }
                    catch { }
                }

                List<Message> lastmessages = blobFactory.MLastMessage().GetWithDefault(new List<Message>());
                lastmessages.Add(message);
                // TODO: Take does *NOT* modify lastmessages :-)
                lastmessages.Take(100);

                blobFactory.MLastMessage().Set(lastmessages);
            }
            catch {
                bMessage.Delete();
                throw;
            }

            // TODO : Add in accountMsg

            return messageId;
        }
Example #2
0
        public Guid Post(Guid accountId, string content)
        {
            Guid id = Guid.NewGuid();
            AccountStorageTmp.FullAccountInfo accountInfo = this.motherStorage.account.GetFullInfo(accountId);
            var message = new Message(id, accountId, accountInfo.AccountInfo.Name, string.Empty, DateTime.Now, content)
                {
                    Content = content,
                    Date = DateTime.Now,
                    Id = id,
                    PosterAvatar = string.Empty,
                    PosterId = accountId,
                    PosterName = accountInfo.AccountInfo.Name
                };

            foreach (var listId in accountInfo.MemberOfLists)
            {
                List<IMessage> messages = this.motherStorage.list.GetFullInfo(listId).Messages;
                messages.Add(message);
            }

            return id;
        }