Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dc"></param>
        public static void AddOrgMembers(this DataContext dc)
        {
            var repo  = new OrgRepository(dc);
            var users = dc.Users.ToList();
            var orgs  = repo.All.Value;

            foreach (var u in users)
            {
                var myOrgs = TestFactory.SelectRandomObjects <ModelOrg>(orgs, 3);

                foreach (var o in myOrgs)
                {
                    repo.AddOrgMember(o.Id, u.Id, TestFactory.GetRandomEnumValue <Role>());
                }

                var currentOrgId = TestFactory.SelectRandomObject <ModelOrg>(orgs).Id;
                new UserRepository(dc).SwitchOrg(u.Id, currentOrgId);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dc"></param>
        public static ModelOrgs AddOrgs(this DataContext dc, int count = 3)
        {
            var repo = new OrgRepository(dc);

            var companies = TestFactory.GetRandomCompanyNames(count);
            var list      = new ModelOrgs();

            foreach (var c in companies)
            {
                var o = new ModelOrg()
                {
                    Name = c
                };

                var op = repo.Create(o, false);
                o.Id = op.Value.Id;

                list.Add(o);
            }

            return(list);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        private void EnsureMainOrg()
        {
            var repo = new OrgRepository(this);

            var main = repo [OrgRepository.DEFAULT_ORG_ID];

            if (main.HasError && main.Error.Code == ErrorCode.BadGetOrg)
            {
                var res = repo.Create(new Security.Org()
                {
                    Id   = OrgRepository.DEFAULT_ORG_ID,
                    Name = OrgRepository.DEFAULT_ORG_NAME
                }, false);

                if (!res.HasError)
                {
                    Logger.Info("Add default org");
                }
                else
                {
                    Logger.Error("Failure to add default org");
                }
            }
        }