private Guid SetData(int type) { var institution = UsingDbContext(e => e.Institution.Add(InitFakeEntity.GetFakeInstitution())); var adminDto = InitFakeEntity.GetFakeAdmin(); adminDto.UserId = Guid.NewGuid(); adminDto.UserType = UserType.Admin; adminDto.InstitutionId = institution.Id; var classDto = InitFakeEntity.GetFakeClassInfo(); classDto.Admins.Add(adminDto); classDto.InstitutionId = institution.Id; for (int i = 0; i < 3; i++) { var studentDto = InitFakeEntity.GetFakeStudent(); studentDto.StudentId = Guid.NewGuid(); studentDto.UserName = studentDto.UserName + i; classDto.Students.Add(studentDto); } var classInfo = UsingDbContext(e => e.ClassInfo.Add(classDto)); var userId = Guid.Empty; for (int i = 0; i < 3; i++) { var setDto = InitFakeEntity.GetFakeSet(); setDto.SetName = setDto.SetName + i; for (int j = 0; j < 3; j++) { var bookDto = InitFakeEntity.GetFakeBook(); bookDto.BookName = bookDto.BookName + i + j; setDto.Books.Add(bookDto); } var set = UsingDbContext(e => e.Sets.Add(setDto)); var orderDto = InitFakeEntity.GetFakeOrder(); orderDto.UserId = classInfo.Admins.First().UserId; orderDto.OrderRef = orderDto.OrderRef + i; orderDto.Paid = true; var order = UsingDbContext(e => e.Order.Add(orderDto)); var adminDto2 = InitFakeEntity.GetFakeAdmin(); adminDto2.UserName = adminDto2.UserName + i; adminDto2.UserId = Guid.NewGuid(); adminDto2.InstitutionId = institution.Id; var classDto2 = InitFakeEntity.GetFakeClassInfo(); classDto2.Admins.Add(adminDto2); classDto2.InstitutionId = institution.Id; classDto2.Name = classDto2.Name + i; for (int k = 0; k < 3; k++) { var studentDto = InitFakeEntity.GetFakeStudent(); studentDto.StudentId = Guid.NewGuid(); studentDto.UserName = studentDto.UserName + i + k; classDto2.Students.Add(studentDto); } var classInfo2 = UsingDbContext(e => e.ClassInfo.Add(classDto2)); userId = classInfo2.Admins.First().UserId; var payment = InitFakeEntity.GetFakePayment(); payment.GatewayRef = payment.GatewayRef + i; payment.Paid = true; payment.OrderRef = order.OrderRef; UsingDbContext(e => e.Payment.Add(payment)); var orderItemDto = InitFakeEntity.GetFakeOrderItem(); orderItemDto.SetId = set.Id; orderItemDto.Set = set; orderItemDto.OrderRef = order.OrderRef; orderItemDto.UserId = order.UserId; var orderItem = UsingDbContext(e => e.OrderItem.Add(orderItemDto)); var teacherAllocationDto = InitFakeEntity.GetFakeTeacherAllocation(); teacherAllocationDto.OrderItemId = orderItem.Id; teacherAllocationDto.SetId = set.Id; teacherAllocationDto.TeacherId = classInfo2.Admins.First().UserId; foreach (var item in classInfo2.Students) { var studentAllocationDto = new StudentAllocation { StudentId = item.StudentId }; teacherAllocationDto.StudentAllocations.Add(studentAllocationDto); } var teacherAllocation = UsingDbContext(e => e.TeacherAllocation.Add(teacherAllocationDto)); } if (type == 1) { return(classInfo.Admins.First().UserId); } else { return(userId); } }
private Guid SetData() { var institution = UsingDbContext(e => e.Institution.Add(InitFakeEntity.GetFakeInstitution())); var adminDto = InitFakeEntity.GetFakeAdmin(); adminDto.UserId = Guid.NewGuid(); adminDto.UserType = UserType.Admin; adminDto.InstitutionId = institution.Id; var classDto = InitFakeEntity.GetFakeClassInfo(); classDto.Admins.Add(adminDto); classDto.InstitutionId = institution.Id; for (int i = 0; i < 3; i++) { var studentDto = InitFakeEntity.GetFakeStudent(); studentDto.StudentId = Guid.NewGuid(); studentDto.UserName = studentDto.UserName + i; classDto.Students.Add(studentDto); } var classInfo = UsingDbContext(e => e.ClassInfo.Add(classDto)); for (int i = 0; i < 3; i++) { var orderDto = InitFakeEntity.GetFakeOrder(); orderDto.UserId = classInfo.Admins.First().UserId; orderDto.OrderRef = orderDto.OrderRef + i; orderDto.Paid = true; var order = UsingDbContext(e => e.Order.Add(orderDto)); var setDto = InitFakeEntity.GetFakeSet(); setDto.SetName = setDto.SetName + i; var set = UsingDbContext(e => e.Sets.Add(setDto)); var orderItemDto = InitFakeEntity.GetFakeOrderItem(); orderItemDto.SetId = set.Id; orderItemDto.OrderRef = order.OrderRef; orderItemDto.UserId = order.UserId; var orderItem = UsingDbContext(e => e.OrderItem.Add(orderItemDto)); var adminDto2 = InitFakeEntity.GetFakeAdmin(); adminDto2.UserName = adminDto2.UserName + i; adminDto2.UserId = Guid.NewGuid(); adminDto2.InstitutionId = institution.Id; var classDto2 = InitFakeEntity.GetFakeClassInfo(); classDto2.Admins.Add(adminDto2); classDto2.InstitutionId = institution.Id; classDto2.Name = classDto2.Name + i; for (int k = 0; k < 3; k++) { var studentDto = InitFakeEntity.GetFakeStudent(); studentDto.StudentId = Guid.NewGuid(); studentDto.UserName = studentDto.UserName + i + k; classDto2.Students.Add(studentDto); } var classInfo2 = UsingDbContext(e => e.ClassInfo.Add(classDto2)); var teacherAllocationDto = InitFakeEntity.GetFakeTeacherAllocation(); teacherAllocationDto.OrderItemId = orderItem.Id; teacherAllocationDto.SetId = set.Id; teacherAllocationDto.TeacherId = classInfo2.Admins.First().UserId; var teacherAllocation = UsingDbContext(e => e.TeacherAllocation.Add(teacherAllocationDto)); UsingDbContext(e => { foreach (var item in classInfo2.Students) { var studentAllocationDto = new StudentAllocation { TeacherAllocationId = teacherAllocation.Id, StudentId = item.StudentId }; e.StudentAllocation.Add(studentAllocationDto); } }); } return(classInfo.Admins.First().UserId); }