Exemple #1
0
        public async Task <InsertResponse> GenerateHistoriesAsync(GenerateItemsRequest request)
        {
            var patientIds = await UserManager.GetUsersIdAsync(new UsersIdRequest
            {
                Amount   = request.Count,
                UserType = UserType.Patient
            });

            var doctorIds = await UserManager.GetUsersIdAsync(new UsersIdRequest
            {
                Amount   = request.Count,
                UserType = UserType.Doctor
            });

            var historyPoints = Builder <HistoryPoint> .CreateNew()
                                .With(e => e.CreationDate = Date.Between(new DateTime(1930, 1, 1), DateTime.UtcNow))
                                .With(e => e.Report       = Faker.Lorem.Paragraph());

            var histories = new Bogus.Faker <History>()
                            .RuleFor(u => u.Id, f => ObjectId.GenerateNewId().ToString())
                            .RuleFor(bp => bp.DoctorId, f => f.PickRandom(doctorIds))
                            .RuleFor(bp => bp.PatientId, f => f.PickRandom(patientIds))
                            .RuleFor(u => u.HistoryPoints, f => f.Make(10, () => historyPoints.Build()))
                            .Generate(request.Count).ToList();

            return(await HistoryRepository.BulkInsertHistoriesAsync(histories));
        }