示例#1
0
        public async Task <InsertResponse> GenerateDepartmentsAsync(GenerateDepartmentsAsync request)
        {
            var hospitalIds = await HospitalManager.GetHospitalsIdAsync();

            var departments = new Faker <Department>()
                              .RuleFor(u => u.Id, f => ObjectId.GenerateNewId().ToString())
                              .RuleFor(bp => bp.Name, f => f.Lorem.Word())
                              .RuleFor(bp => bp.HospitalId, f => f.PickRandom(hospitalIds))
                              .RuleFor(u => u.Type, f => f.PickRandom <DepartmentType>())
                              .RuleFor(u => u.DepartmentInfo, f => f.Lorem.Paragraph())
                              .Generate(request.Count).ToList();

            return(await DepartmentRepository.BulkInsertDepartmentsAsync(departments));
        }