public void TestCreateMoreParty() { using (UnitOfWork unitwork = new UnitOfWork(store, dbContextFactory)) { IRepository<Post, Guid> postRepository = new Repository<Post, Guid>(store); IRepository<Employee, Guid> employeeRepository = new Repository<Employee, Guid>(store); IRepository<PartyHierarchy, Guid> partyHierarchyRepository = new Repository<PartyHierarchy, Guid>(store); Employee employee = new Employee() { Name = "Bob", }; Post post = new Post() { Name = "總經理室副主管", }; Post parentPost = postRepository.Query(q => q.Name == "總經理室主管").First(); employeeRepository.SaveOrUpdate(employee); postRepository.SaveOrUpdate(post); PartyService partyService = new PartyService(partyHierarchyRepository); partyService.AddAccountability(parentPost, post); unitwork.SaveChanges(); partyService.AddEmployeeToPost(post, employee); unitwork.SaveChanges(); } }
public void TestAddEmployeeToPost() { using (UnitOfWork unitwork = new UnitOfWork(store, dbContextFactory)) { IRepository<Employee, Guid> empRepository = new Repository<Employee, Guid>(store); IRepository<Post, Guid> roleRepository = new Repository<Post, Guid>(store); IRepository<PartyHierarchy, Guid> partyHireRepository = new Repository<PartyHierarchy, Guid>(store); Employee prt1 = new Employee() { Name = "Allen" }; Employee prt2 = new Employee() { Name = "Bob" }; Employee prt3 = new Employee() { Name = "Cary" }; Employee prt4 = new Employee() { Name = "David" }; Employee prt5 = new Employee() { Name = "Edward" }; Employee prt6 = new Employee() { Name = "Fred" }; Employee prt7 = new Employee() { Name = "Gallon" }; Employee prt8 = new Employee() { Name = "Hellen" }; Employee prt9 = new Employee() { Name = "Ian" }; Employee prt10 = new Employee() { Name = "Ivy" }; Employee prt11 = new Employee() { Name = "Jay" }; Employee prt12 = new Employee() { Name = "Kalad" }; Employee prt13 = new Employee() { Name = "Larry" }; Employee prt14 = new Employee() { Name = "Moppies" }; Employee prt15 = new Employee() { Name = "Nana" }; Employee prt16 = new Employee() { Name = "Outu" }; empRepository.SaveOrUpdate(prt1); empRepository.SaveOrUpdate(prt2); empRepository.SaveOrUpdate(prt4); empRepository.SaveOrUpdate(prt5); empRepository.SaveOrUpdate(prt6); empRepository.SaveOrUpdate(prt7); empRepository.SaveOrUpdate(prt8); empRepository.SaveOrUpdate(prt9); empRepository.SaveOrUpdate(prt10); empRepository.SaveOrUpdate(prt11); empRepository.SaveOrUpdate(prt12); empRepository.SaveOrUpdate(prt13); empRepository.SaveOrUpdate(prt14); empRepository.SaveOrUpdate(prt15); empRepository.SaveOrUpdate(prt16); PartyService service = new PartyService(partyHireRepository); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "總經理室主管").First(), prt1); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "總經理室副主管").First(), prt2); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "總經理室秘書").First(), prt3); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "人資部主管").First(), prt4); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "人資部副主管").First(), prt5); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "企畫課主管").First(), prt6); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "企畫課副主管").First(), prt7); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "企畫課成員").First(), prt8); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "管理課主管").First(), prt9); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "管理課副主管").First(), prt10); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "管理課成員").First(), prt11); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "業務部主管").First(), prt12); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "業務部副主管").First(), prt13); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "業務一課主管").First(), prt14); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "業務一課副主管").First(), prt15); service.AddEmployeeToPost(roleRepository.Query(q => q.Name == "業務一課成員").First(), prt16); unitwork.SaveChanges(); } }
public void TestCreateParty() { using (UnitOfWork unitwork = new UnitOfWork(store, dbContextFactory)) { IRepository<Party, Guid> partyRepository = new Repository<Party, Guid>(store); //用partyRepository也可以存進去,不知差別在哪 IRepository<Employee, Guid> employeeRepository = new Repository<Employee, Guid>(store); IRepository<Post, Guid> postRepository = new Repository<Post, Guid>(store); IRepository<PartyHierarchy, Guid> partyHierarchyRepository = new Repository<PartyHierarchy, Guid>(store); Employee employee = new Employee() { Name = "Allen" }; Post post = new Post() { Name = "總經理室主管" }; employeeRepository.SaveOrUpdate(employee); postRepository.SaveOrUpdate(post); PartyService partyService = new PartyService(partyHierarchyRepository); partyService.AddEmployeeToPost(post,employee); unitwork.SaveChanges(); } }