Inheritance: IListInfo
Beispiel #1
0
        public Guid Create(Guid ownerId, string name, string description, bool isPrivate)
        {
            // Create the data :
            Guid           listId            = Guid.NewGuid();
            ListInfo       info              = new ListInfo(name, description, isPrivate, false);
            HashSet <Guid> followingAccounts = new HashSet <Guid>();

            followingAccounts.Add(ownerId);

            // Creation of blobs in list container
            Blob <ListInfo>        bInfo              = blobFactory.LInfo(listId);
            Blob <Guid>            bOwner             = blobFactory.LOwner(listId);
            HashSetBlob <Guid>     bOwned             = isPrivate ? blobFactory.LOwnedListsPrivate(ownerId) : blobFactory.LOwnedListsPublic(ownerId);
            Blob <HashSet <Guid> > bFollowingAccounts = blobFactory.LFollowingAccounts(listId);
            DictionaryBlob <Guid>  bFollowedAccounts  = blobFactory.LFollowedAccounts(listId);
            HashSetBlob <Guid>     bAddRmvMsgs        = blobFactory.LAddRmvMsgs(listId);
            MsgSetBlobPack         bMessages          = blobFactory.MListMessages(listId);

            // store the data
            blobFactory.LInfo(listId).Set(info);
            bOwner.Set(ownerId);
            bFollowingAccounts.Set(followingAccounts);
            bFollowedAccounts.Set(new Dictionary <Guid, bool>());
            bAddRmvMsgs.Set(new HashSet <Guid>());

            bMessages.Init();

            // add the lists to owned lists and check that the user exists. if he doesn't, delete the data stored
            if (!bOwned.AddWithRetry(listId))
            {
                bInfo.Delete();
                bOwner.Delete();
                bFollowingAccounts.Delete();
                bFollowedAccounts.Delete();
                bMessages.Delete();
                bAddRmvMsgs.Delete();

                throw new AccountNotFound();
            }

            return(listId);
        }
Beispiel #2
0
        public Guid Create(Guid ownerId, string name, string description, bool isPrivate)
        {
            // Create the data :
            Guid listId = Guid.NewGuid();
            ListInfo info = new ListInfo(name, description, isPrivate, false);
            HashSet<Guid> followingAccounts = new HashSet<Guid>();
            followingAccounts.Add(ownerId);

            // Creation of blobs in list container
            Blob<ListInfo> bInfo = blobFactory.LInfo(listId);
            Blob<Guid> bOwner = blobFactory.LOwner(listId);
            HashSetBlob<Guid> bOwned = isPrivate ? blobFactory.LOwnedListsPrivate(ownerId) : blobFactory.LOwnedListsPublic(ownerId);
            Blob<HashSet<Guid>> bFollowingAccounts = blobFactory.LFollowingAccounts(listId);
            DictionaryBlob<Guid> bFollowedAccounts = blobFactory.LFollowedAccounts(listId);
            HashSetBlob<Guid> bAddRmvMsgs = blobFactory.LAddRmvMsgs(listId);
            MsgSetBlobPack bMessages = blobFactory.MListMessages(listId);

            // store the data
            blobFactory.LInfo(listId).Set(info);
            bOwner.Set(ownerId);
            bFollowingAccounts.Set(followingAccounts);
            bFollowedAccounts.Set(new Dictionary<Guid,bool>());
            bAddRmvMsgs.Set(new HashSet<Guid>());

            bMessages.Init();

            // add the lists to owned lists and check that the user exists. if he doesn't, delete the data stored
            if (!bOwned.AddWithRetry(listId))
            {
                bInfo.Delete();
                bOwner.Delete();
                bFollowingAccounts.Delete();
                bFollowedAccounts.Delete();
                bMessages.Delete();
                bAddRmvMsgs.Delete();

                throw new AccountNotFound();
            }

            return listId;
        }