LOwner() public method

public LOwner ( System.Guid listId ) : Blob
listId System.Guid
return Blob
Beispiel #1
0
        public Guid Create(Guid adminId, string name, string description, bool bypassNameReservation = false)
        {
            Blob <Guid> bIdByName = blobFactory.AIdByName(name);

            // lock the name
            if (!bypassNameReservation)
            {
                if (!bIdByName.SetIfNotExists(Guid.Empty))
                {
                    throw new AccountAlreadyExists();
                }
            }

            Guid accountId = Guid.NewGuid();

            // TODO : we could do it without a lock - or at least store the data before
            using (blobFactory.UAccountsLock(adminId))
            {
                Guid personnalListId = Guid.NewGuid();

                // store the data
                HashSet <Guid> users = new HashSet <Guid>();
                users.Add(adminId);
                blobFactory.AUsers(accountId).Set(users);

                HashSet <Guid> followedByAll = new HashSet <Guid>();
                followedByAll.Add(personnalListId);
                blobFactory.LFollowedByAll(accountId).Set(followedByAll);

                blobFactory.AInfo(accountId).Set(new AccountInfo(name, description));
                blobFactory.AAdminId(accountId).Set(adminId);
                blobFactory.LOwnedListsPublic(accountId).Set(new HashSet <Guid>());
                blobFactory.LOwnedListsPrivate(accountId).Set(new HashSet <Guid>());
                blobFactory.LFollowedListsData(accountId).Set(new HashSet <Guid>());
                blobFactory.LFollowedByPublic(accountId).Set(new HashSet <Guid>());
                blobFactory.LFollowedListsLockInit(accountId);
                blobFactory.MTaggedMessages(accountId).Init();
                blobFactory.AAutocompletion().Add(new KeyValuePair <string, string>(name.GenerateDoubleMetaphone(), name));

                // Setup the personnal list
                blobFactory.LPersonnalList(accountId).Set(personnalListId);
                blobFactory.LInfo(personnalListId).Set(new ListInfo("", "", true, true));
                blobFactory.LOwner(personnalListId).Set(accountId);
                blobFactory.MListMessages(personnalListId).Init();
                blobFactory.LFollowedAccounts(personnalListId).Set(new Dictionary <Guid, bool>());

                // we finish by unlocking the name
                bIdByName.Set(accountId);

                // we make this account accessible
                blobFactory.UAccountsData(adminId).Add(accountId);
            }

            return(accountId);
        }
Beispiel #2
0
 public Guid GetOwner(Guid listId)
 {
     return(blobFactory.LOwner(listId).GetIfExists(new ListNotFound()));
 }