当前位置: 首页>>代码示例>>C#>>正文


C# Employee.AddRole方法代码示例

本文整理汇总了C#中Employee.AddRole方法的典型用法代码示例。如果您正苦于以下问题:C# Employee.AddRole方法的具体用法?C# Employee.AddRole怎么用?C# Employee.AddRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Employee的用法示例。


在下文中一共展示了Employee.AddRole方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldAddRoleToEmployee

        public void ShouldAddRoleToEmployee()
        {
            var employee = new Employee();
            employee.AddRole(new Role("test role"));

            Role[] roles = employee.GetRoles();
            Assert.That(roles.Length, Is.EqualTo(1));
        }
开发者ID:fyulnady,项目名称:CMBootCamp,代码行数:8,代码来源:EmployeeTester.cs

示例2: ShouldPersistRolesCollection

        public void ShouldPersistRolesCollection()
        {
            new DatabaseTester().Clean();

            var one = new Employee("1", "first1", "last1", "email1");
            one.AddRole(new Role("admin"));
            one.AddRole(new Role("user"));
            using (ISession session = DataContext.GetTransactedSession())
            {
                session.Save(one);
                session.Transaction.Commit();
            }

            Employee rehydratedEmployee;
            using (ISession session = DataContext.GetTransactedSession())
            {
                rehydratedEmployee = session.Load<Employee>(one.Id);
            }

            rehydratedEmployee.GetRoles().Length.ShouldEqual(2);
            rehydratedEmployee.GetRoles().Count(role => role.Name == "admin").ShouldEqual(1);
            rehydratedEmployee.GetRoles().Count(role => role.Name == "user").ShouldEqual(1);
        }
开发者ID:fyulnady,项目名称:CMBootCamp,代码行数:23,代码来源:EmployeeMappingTester.cs

示例3: ShouldGetAllEmployeesForFulfillment

        public void ShouldGetAllEmployeesForFulfillment()
        {
            new DatabaseTester().Clean();

            ISession session = DataContext.GetTransactedSession();
            var role = new Role("foo");
            var one = new Employee("1", "first1", "last1", "email1");
            one.AddRole(role);
            var two = new Employee("2", "first2", "last2", "email2");
            two.AddRole(role);
            var three = new Employee("3", "first3", "last3", "email3");
            session.SaveOrUpdate(role);
            session.SaveOrUpdate(two);
            session.SaveOrUpdate(three);
            session.SaveOrUpdate(one);
            session.Transaction.Commit();
            session.Dispose();

            IEmployeeRepository repository = new EmployeeRepository();
            Employee[] employees =
                repository.GetEmployees(new EmployeeSpecification(true));

            Assert.That(employees.Length, Is.EqualTo(2));
        }
开发者ID:fyulnady,项目名称:CMBootCamp,代码行数:24,代码来源:EmployeeRepositoryTester.cs

示例4: PopulateDatabase

        public void PopulateDatabase()
        {
            new DatabaseTester().Clean();
            ISession session = DataContext.GetTransactedSession();

            var lead = new Role("Facility Lead");
            var fulfillment = new Role("Fulfillment");
            session.SaveOrUpdate(lead);
            session.SaveOrUpdate(fulfillment);

            //Trainer1
            var jpalermo = new Employee("jpalermo", "Jeffrey", "Palermo", "[email protected]");
            jpalermo.AddRole(lead);
            jpalermo.AddRole(fulfillment);
            session.SaveOrUpdate(jpalermo);

            //Person 1

            //Person 2

            //Person 3

            //Person 4

            //Person 5

            //Person 6

            //Person 7

            //Person 8

            //Person 9

            //Person 10

            //Person 11

            //Person 12

            //Person 13

            var hsimpson = new Employee("hsimpson", "Homer", "Simpson", "[email protected]");
            hsimpson.AddRole(fulfillment);
            session.SaveOrUpdate(hsimpson);

            foreach (ExpenseReportStatus status in ExpenseReportStatus.GetAllItems())
            {
                var order = new ExpenseReport();
                order.Number = Guid.NewGuid().ToString().Substring(0, 5).ToUpper();
                order.Submitter = jpalermo;
                order.Approver = jpalermo;
                order.Status = status;
                order.Title = "Work Order starting in status " + status;
                order.Description = "Foo, foo, foo, foo " + status;
                order.CreatedDate = new DateTime(2000, 1, 1, 8, 0, 0);
                new DateTime(2000, 1, 1, 8, 0, 0);
                order.ChangeStatus(ExpenseReportStatus.Draft);
                order.ChangeStatus(ExpenseReportStatus.Submitted);
                order.ChangeStatus(ExpenseReportStatus.Approved);

                session.SaveOrUpdate(order);
            }

            var order2 = new ExpenseReport();
            order2.Number = Guid.NewGuid().ToString().Substring(0, 5).ToUpper();
            order2.Submitter = jpalermo;
            order2.Approver = jpalermo;
            order2.Status = ExpenseReportStatus.Approved;
            order2.Title = "Work Order starting in status ";
            order2.Description = "Foo, foo, foo, foo ";
            order2.CreatedDate = new DateTime(2000, 1, 1, 8, 0, 0);
            new DateTime(2000, 1, 1, 8, 0, 0);
            session.SaveOrUpdate(order2);

            session.Transaction.Commit();
            session.Dispose();
        }
开发者ID:fyulnady,项目名称:CMBootCamp,代码行数:78,代码来源:ZDataLoader.cs

示例5: Foo6

        public void Foo6()
        {
            ISession session = DataContext.GetTransactedSession();
            Role role = new Role("");
            Employee employee = new Employee("1", "1", "1", "1");
            employee.AddRole(role);

            session.SaveOrUpdate(employee);
            session.Transaction.Commit();
        }
开发者ID:fyulnady,项目名称:CMBootCamp,代码行数:10,代码来源:ScratchTester.cs

示例6: ShouldSaveRolesWithEmployee

        public void ShouldSaveRolesWithEmployee()
        {
            new DatabaseTester().Clean();
            var role1 = new Role("foo");
            var role2 = new Role("bar");
            var emp1 = new Employee("1", "first1", "last1", "email1");
            emp1.AddRole(role1);
            emp1.AddRole(role2);

            ISession session = DataContext.GetTransactedSession();
            session.SaveOrUpdate(role1);
            session.SaveOrUpdate(role2);
            session.SaveOrUpdate(emp1);
            session.Transaction.Commit();
            session.Dispose();

            ISession session2 = DataContext.GetTransactedSession();
            var rehydratedEmployee = session2.Load<Employee>(emp1.Id);
            Assert.That(rehydratedEmployee.GetRoles().Length,
                        Is.EqualTo(2));
        }
开发者ID:fyulnady,项目名称:CMBootCamp,代码行数:21,代码来源:EmployeeRepositoryTester.cs


注:本文中的Employee.AddRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。