Example #1
0
        public void BuildData()
        {
            data = new DataBuilder(contextBuilder)
                   .CreateDummyOrganization().CreateDummyTerm().CreateDummyUserWithRoleToOrganization(RoleEnum.SuperAdmin);

            //data.createDummySchool()
            data.CreateDummySchool(data.organizationBuilder.organization.Id, false, false, true, false, 50);

            organizationServices = new OrganizationServices(contextBuilder.GetContext());
            List <Organization> subOrganizations = organizationServices.GetSubOrganisations(data.organization.Id);
            List <Organization> classrooms       = organizationServices.GetSubOrganisations(data.organization.Id)
                                                   .Where(i => i.OrganTypeId == AppSettings.OrganizationTypeId.Classroom ||
                                                          i.OrganTypeId == AppSettings.OrganizationTypeId.ClassroomWithoutBranch).ToList();

            data.CreateListDummyUserInRangeWithRoleToOrganization(subOrganizations.Where(i => i.OrganTypeId == AppSettings.OrganizationTypeId.School).FirstOrDefault(),
                                                                  RoleEnum.LeaderTeacher, 1);
            //Kullanacagim rehber ogretmeni sakliyorum
            leaderTeacher = data.user;

            students = new List <User>();
            foreach (Organization item in classrooms)
            {
                students.AddRange(data.CreateListDummyUserInRangeWithRoleToOrganization(item, RoleEnum.Student, 1));
                data.SetAccessClassroom(leaderTeacher, item.Id);
            }
        }
Example #2
0
        public void BuildData()
        {
            contextBuilder.ClearAllContext();
            organizationServices = new OrganizationServices(contextBuilder.GetContext());
            //Create Data
            dataBuilder = new DataBuilder(contextBuilder)
                          .CreateDummyOrganization()
                          .CreateDummyTerm()
                          .CreateDummyUserWithRoleToOrganization(RoleEnum.Operator);
            dataBuilder.CreateDummySchool(dataBuilder.organizationBuilder.organization.Id, true, true, true, true, 3);
            organizationServices = new OrganizationServices(contextBuilder.GetContext());
            List <Organization> subOrganizations = organizationServices.GetSubOrganisations(dataBuilder.organization.Id);
            List <User>         operatorUsers    = new List <User>();

            foreach (Organization item in subOrganizations)
            {
                if (item.OrganTypeId == AppSettings.OrganizationTypeId.School)
                {
                    dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(item, RoleEnum.LeaderTeacher, 1);
                }

                else if (item.OrganTypeId == AppSettings.OrganizationTypeId.Classroom || item.OrganTypeId == AppSettings.OrganizationTypeId.ClassroomWithoutBranch)
                {
                    dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(item, RoleEnum.Student, 20);
                    dataBuilder.SetRoleToOrganization(dataBuilder.user, item, RoleEnum.LeaderTeacher);
                    //data.createListDummyUserWithRoleToOrganization(item, RoleEnum.LeaderTeacher);
                }
            }

            foreach (Organization item in subOrganizations)
            {
                operatorUsers = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(item, RoleEnum.Operator, 1);
            }
            operatorUser = operatorUsers[0];
            dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), operatorUser.Id, 160);
        }
Example #3
0
        public void CreateAlternativeSchool()
        {
            ClearLists();
            dataBuilder = new DataBuilder(contextBuilder).CreateDummyOrganization().CreateDummyTerm();
            dataBuilder.CreateDummySchool(dataBuilder.organizationBuilder.organization.Id, true, true, true, true, 3);
            allOrganizations = organizationServices.GetSubOrganisations(dataBuilder.organization.Id);
            school           = allOrganizations.Where(j => j.OrganTypeId == AppSettings.OrganizationTypeId.School).ToList()[0];

            User newManager = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(school, RoleEnum.Manager, 1)[0];

            dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), newManager.Id, new Random().Next(1, 162));
            managerUser = newManager;
            User newLeaderTeacher = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(school, RoleEnum.LeaderTeacher, 1)[0];

            dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), newLeaderTeacher.Id, new Random().Next(1, 162));
            leaderTeacherUser = newLeaderTeacher;

            foreach (Organization classroom in allOrganizations)
            {
                // Organizations we are iterating needs to be either a classroom or classroom without branch which are all types but preschool.
                // Preschool has branches (Either age based distribution or animal names etc.)
                if (classroom.OrganTypeId == AppSettings.OrganizationTypeId.Classroom || classroom.OrganTypeId == AppSettings.OrganizationTypeId.ClassroomWithoutBranch)
                {
                    dataBuilder.SetAccessClassroom(leaderTeacherUser, classroom.Id);
                    if (-5 <= classroom.Level && classroom.Level <= -3)
                    {
                        preSchoolClassrooms.Add(allOrganizations.Where(i => i.Level == classroom.Level).FirstOrDefault());
                        allClassrooms.Add(allOrganizations.Where(i => i.Level == classroom.Level).FirstOrDefault());
                        User newParent = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Parent, 1)[0];
                        dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), newParent.Id, new Random().Next(1, 162));
                        User classTeacher = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Teacher, 1)[0];
                        dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), classTeacher.Id, new Random().Next(1, 162));
                        allClassTeachers.Add(classTeacher);
                        preSchoolTeachers.Add(classTeacher);
                        allParents.Add(newParent);
                        preSchoolParents.Add(newParent);
                        preSchoolStudents.AddRange(dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Student, 4));
                    }
                    else if (1 <= classroom.Level && classroom.Level <= 4)
                    {
                        primarySchoolClassrooms.Add(allOrganizations.Where(i => i.Level == classroom.Level).FirstOrDefault());
                        allClassrooms.Add(allOrganizations.Where(i => i.Level == classroom.Level).FirstOrDefault());
                        User newParent = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Parent, 1)[0];
                        dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), newParent.Id, new Random().Next(1, 162));
                        User classTeacher = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Teacher, 1)[0];
                        dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), classTeacher.Id, new Random().Next(1, 162));
                        allClassTeachers.Add(classTeacher);
                        primarySchoolTeachers.Add(classTeacher);
                        allParents.Add(newParent);
                        primarySchoolParents.Add(newParent);
                        primarySchoolStudents.AddRange(dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Student, 4));
                    }
                    else if (5 <= classroom.Level && classroom.Level <= 8)
                    {
                        secondarySchoolClassrooms.Add(allOrganizations.Where(i => i.Level == classroom.Level).FirstOrDefault());
                        allClassrooms.Add(allOrganizations.Where(i => i.Level == classroom.Level).FirstOrDefault());
                        User newParent = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Parent, 1)[0];
                        dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), newParent.Id, new Random().Next(1, 162));
                        User classTeacher = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Teacher, 1)[0];
                        dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), classTeacher.Id, new Random().Next(1, 162));
                        allClassTeachers.Add(classTeacher);
                        secondarySchoolTeachers.Add(classTeacher);
                        allParents.Add(newParent);
                        secondarySchoolParents.Add(newParent);
                        secondarySchoolStudents.AddRange(dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Student, 4));
                    }
                    else if (9 <= classroom.Level && classroom.Level <= 12)
                    {
                        highSchoolClassrooms.Add(allOrganizations.Where(i => i.Level == classroom.Level).FirstOrDefault());
                        allClassrooms.Add(allOrganizations.Where(i => i.Level == classroom.Level).FirstOrDefault());
                        User newParent = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Parent, 1)[0];
                        dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), newParent.Id, new Random().Next(1, 162));
                        User classTeacher = dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Teacher, 1)[0];
                        dataBuilder.userBuilder.SetTemperament(contextBuilder.GetContext(), classTeacher.Id, new Random().Next(1, 162));
                        allClassTeachers.Add(classTeacher);
                        highSchoolTeachers.Add(classTeacher);
                        allParents.Add(newParent);
                        highSchoolParents.Add(newParent);
                        highSchoolStudents.AddRange(dataBuilder.CreateListDummyUserInRangeWithRoleToOrganization(classroom, RoleEnum.Student, 4));
                    }
                    else // s: -2, -1, 0
                    {
                        // Console.WriteLine("This shouldn't happen.");
                    }
                }
            }
            allStudents.AddRange(preSchoolStudents);
            allStudents.AddRange(primarySchoolStudents);
            allStudents.AddRange(secondarySchoolStudents);
            allStudents.AddRange(highSchoolStudents);
            foreach (User student in allStudents)
            {
                var studentNo = new Random().Next(1000, 9999) + "";
                userBuilder.AddPropertyToUser("schoolNo", studentNo, student);

                // For every student we created (wow!), assign them a parent from their classroom.
                var studentOrganisationID = contextBuilder.GetContext().UserOrganizationRoles.Where(uor => student.Id == uor.UserId).FirstOrDefault().OrganizationId;
                var parentRoleID          = "13676A48-FC7A-4694-82B2-CF0EE8F06313";
                var parentID = contextBuilder.GetContext().UserOrganizationRoles.Where(uor => uor.OrganizationId == studentOrganisationID && uor.RoleId == new Guid(parentRoleID)).FirstOrDefault().UserId;
                dataBuilder.AssignParentToStudent(parentID, student.Id);
            }
        }