· 5 years ago · May 12, 2020, 11:00 PM
1DECLARE @counter INT;
2DECLARE @voucherCounter INT;
3DECLARE @isPayAsYouGoEnable BIT;
4DECLARE @totalPrepaidCount INT;
5DECLARE @totalPostpaidCount INT;
6DECLARE @expiresInDays INT;
7DECLARE @userID BIGINT;
8DECLARE @voucherSettingsID BIGINT;
9SET @counter = 0;
10
11WHILE (@counter < 10000)
12BEGIN
13 SET @isPayAsYouGoEnable = IIF(@counter % 3 = 1, 0, 1);
14 SET @totalPrepaidCount = ABS(CHECKSUM(NEWID()) % 51) + 20;
15 SET @totalPostpaidCount = IIF(@isPayAsYouGoEnable = 1, ABS(CHECKSUM(NEWID()) % 21), 0);
16 SET @expiresInDays = @counter % 30 + 30;
17
18 INSERT INTO [VoucherSettings]
19 ([IsEnabled], [IsPayAsYouGoEnabled], [ExpiresInDays], [TotalPrepaidCount], [MaxAvailablePostpaidCount])
20 VALUES
21 (1, @isPayAsYouGoEnable, @expiresInDays, @totalPrepaidCount, @totalPostpaidCount);
22
23 SET @voucherSettingsID = SCOPE_IDENTITY();
24
25 INSERT INTO [Users]
26 ([UserName], [RegistrationDate], [AuthCode], [AuthCodeCreated], [RoleID], [AuthToken], [AuthTokenCreated], [VoucherSettingID])
27 VALUES
28 (CONVERT(nvarchar(255), NEWID()) + '@gmail.com', GETUTCDATE(), 0, GETUTCDATE(), 2, '0', GETUTCDATE(), @voucherSettingsID);
29
30 SET @userID = SCOPE_IDENTITY();
31 INSERT INTO [UserProfiles]
32 ([UserProfileID], [FirstName], [LastName], [MarketingPreferences], [TermsConditionsConfirmed], [PrivacyPolicyConfirmed], [DateOfBirth])
33 VALUES
34 (
35 @userID,
36 IIF(@counter % 4 = 0, 'John', IIF(@counter % 4 = 1, 'Mary', IIF(@counter % 4 = 2, 'Oswald', 'Jessica'))),
37 IIF(@counter % 3 = 0, 'Carstone', IIF(@counter % 4 = 1, 'Oliwander', IIF(@counter % 4 = 2, 'Watson', 'Gremn'))),
38 1,
39 GETUTCDATE(),
40 GETUTCDATE(),
41 GETUTCDATE()
42 );
43
44 SET @voucherCounter = 0;
45 WHILE (@voucherCounter < 20)
46 BEGIN
47 INSERT INTO [Vouchers]
48 ([RequestedByID], [RequestedAt], [VoucherCode], [ExpiresAt])
49 VALUES
50 (@userID, GETUTCDATE(), CONVERT(nvarchar(255), NEWID()), DATEADD(day, @expiresInDays, GETUTCDATE()))
51 SET @voucherCounter = @voucherCounter + 1;
52 END
53
54 SET @counter = @counter + 1;
55END;