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); }
public IAccountInfo GetInfo(Guid accountId) { return(blobFactory.AInfo(accountId).GetIfExists(new AccountNotFound())); }