Пример #1
0
        private void Init()
        {
            //Create users
            UserTep usr1 = new UserTep(context);

            usr1.Username = "******";
            usr1.Store();

            UserTep usr2 = new UserTep(context);

            usr2.Username = "******";
            usr2.Store();

            UserTep usr3 = new UserTep(context);

            usr3.Username = "******";
            usr3.Store();

            UserTep usr4 = new UserTep(context);

            usr4.Username = "******";
            usr4.Store();

            //create domains
            Domain domain = new Domain(context);

            domain.Identifier = "myDomainTest";
            domain.Kind       = DomainKind.Public;
            domain.Store();

            Domain domain2 = new Domain(context);

            domain2.Identifier = "otherDomainTest";
            domain2.Kind       = DomainKind.Hidden;
            domain2.Store();

            Role role = new Role(context);

            role.Identifier = "member-test";
            role.Store();

            role.IncludePrivilege(Privilege.FromIdentifier(context, "wpsjob-v"));
            role.IncludePrivilege(Privilege.FromIdentifier(context, "wpsjob-s"));

            //Add users in the domain
            role.GrantToUser(usr1, domain);
            role.GrantToUser(usr2, domain);
            role.GrantToUser(usr3, domain);
            role.GrantToUser(usr3, domain2);

            //create community
            ThematicCommunity community1 = new ThematicCommunity(context);

            community1.Identifier = "community-public-1";
            community1.Kind       = DomainKind.Public;
            community1.Store();
            community1.SetOwner(usr3);
        }
Пример #2
0
        private void Init()
        {
            //Create users
            UserTep usr1 = new UserTep(context);

            usr1.Username = "******";
            usr1.Store();

            UserTep usr2 = new UserTep(context);

            usr2.Username = "******";
            usr2.Store();

            UserTep usr3 = new UserTep(context);

            usr3.Username = "******";
            usr3.Store();

            //create communities
            ThematicCommunity community1 = new ThematicCommunity(context);

            community1.Identifier = "community-public-1";
            community1.Kind       = DomainKind.Public;
            community1.Store();
            community1.SetOwner(usr2);

            ThematicCommunity community2 = new ThematicCommunity(context);

            community2.Identifier = "community-private-1";
            community2.Kind       = DomainKind.Hidden;
            community2.Store();
            community2.SetOwner(usr2);

            ThematicCommunity community3 = new ThematicCommunity(context);

            community3.Identifier = "community-private-2";
            community3.Kind       = DomainKind.Hidden;
            community3.Store();
            community3.SetOwner(usr2);

            ThematicCommunity community4 = new ThematicCommunity(context);

            community4.Identifier = "community-public-2";
            community4.Kind       = DomainKind.Public;
            community4.Store();
            community4.SetOwner(usr2);
        }
Пример #3
0
        /// <summary>
        /// Post the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Post(CreateDomainOwnerRequest request)
        {
            var       context = TepWebContext.GetWebContext(PagePrivileges.AdminOnly);
            WebDomain result;

            try {
                context.Open();
                context.LogInfo(this, string.Format("/domain/{{id}}/owner POST Id='{0}', UserId='{1}'", request.Id, request.UserId));
                ThematicCommunity domain = ThematicCommunity.FromId(context, request.Id);
                UserTep           owner  = UserTep.FromId(context, request.UserId);
                domain.SetOwner(owner);

                result = new WebDomain(domain);

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(result);
        }