Skip to content

Commit 68b15b1

Browse files
authored
Merge pull request #29 from dddsw/seed-2025
Seed 2025 data and pull breaks from sessionize
2 parents 139c705 + 0408846 commit 68b15b1

7 files changed

Lines changed: 198 additions & 153 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
using PocketDDD.Shared.API.RequestDTOs;
2+
using PocketDDD.Shared.API.ResponseDTOs;
3+
4+
namespace PocketDDD.BlazorClient.Services;
5+
6+
public class FakePocketDDDApiService : IPocketDDDApiService
7+
{
8+
public Task<LoginResultDTO> Login(string name)
9+
{
10+
return Task.FromResult(new LoginResultDTO(name, Guid.NewGuid().ToString()));
11+
}
12+
13+
public void SetUserAuthToken(string token)
14+
{
15+
}
16+
17+
public async Task<EventDataResponseDTO?> FetchLatestEventData(EventDataUpdateRequestDTO requestDTO)
18+
{
19+
if (requestDTO.Version == 1)
20+
{
21+
await Task.Delay(1000);
22+
return null;
23+
}
24+
25+
return
26+
new EventDataResponseDTO
27+
{
28+
Version = 1,
29+
TimeSlots = new[]
30+
{
31+
new TimeSlotDTO
32+
{
33+
Id = 1,
34+
From = new DateTimeOffset(2023, 4, 29, 8, 00, 0, TimeSpan.Zero),
35+
To = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
36+
Info = "Registration"
37+
},
38+
new TimeSlotDTO
39+
{
40+
Id = 2,
41+
From = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
42+
To = new DateTimeOffset(2023, 4, 29, 9, 0, 0, TimeSpan.Zero),
43+
Info = "Intro"
44+
},
45+
new TimeSlotDTO
46+
{
47+
Id = 3,
48+
From = new DateTimeOffset(2023, 4, 29, 9, 00, 0, TimeSpan.Zero),
49+
To = new DateTimeOffset(2023, 4, 29, 10, 00, 0, TimeSpan.Zero)
50+
},
51+
new TimeSlotDTO
52+
{
53+
Id = 4,
54+
From = new DateTimeOffset(2023, 4, 29, 10, 0, 0, TimeSpan.Zero),
55+
To = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
56+
Info = "Coffee"
57+
},
58+
new TimeSlotDTO
59+
{
60+
Id = 5,
61+
From = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
62+
To = new DateTimeOffset(2023, 4, 29, 11, 20, 0, TimeSpan.Zero)
63+
}
64+
},
65+
Tracks = new[]
66+
{
67+
new TrackDTO { Id = 1, Name = "Track 1", RoomName = "Room 1" },
68+
new TrackDTO { Id = 2, Name = "Track 2", RoomName = "Room 2" },
69+
new TrackDTO { Id = 3, Name = "Track 3", RoomName = "Room 3" }
70+
},
71+
Sessions = new[]
72+
{
73+
new SessionDTO
74+
{
75+
Id = 1,
76+
FullDescription = "Some full desk",
77+
Speaker = "Ross",
78+
TimeSlotId = 3,
79+
TrackId = 1,
80+
Title = "Blazor Session Management"
81+
},
82+
new SessionDTO
83+
{
84+
Id = 2,
85+
FullDescription = "Second session",
86+
Speaker = "Jim",
87+
TimeSlotId = 3,
88+
TrackId = 2,
89+
Title = "How to code"
90+
},
91+
new SessionDTO
92+
{
93+
Id = 3,
94+
FullDescription = "Third session",
95+
Speaker = "Bob",
96+
TimeSlotId = 5,
97+
TrackId = 2,
98+
Title = "Off by 1"
99+
}
100+
}
101+
};
102+
}
103+
104+
public Task<FeedbackResponseDTO> SubmitClientEventFeedback(SubmitEventFeedbackDTO feedbackDTO)
105+
{
106+
return Task.FromResult(new FeedbackResponseDTO { ClientId = feedbackDTO.ClientId, Score = 2 });
107+
}
108+
109+
public Task<FeedbackResponseDTO> SubmitClientSessionFeedback(SubmitSessionFeedbackDTO feedbackDTO)
110+
{
111+
return Task.FromResult(new FeedbackResponseDTO { ClientId = feedbackDTO.ClientId, Score = 3 });
112+
}
113+
}
Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System.Net;
2-
using System.Net.Http.Headers;
32
using System.Net.Http.Json;
4-
using MudBlazor;
5-
using PocketDDD.Shared.API.ResponseDTOs;
63
using PocketDDD.Shared.API.RequestDTOs;
4+
using PocketDDD.Shared.API.ResponseDTOs;
75

86
namespace PocketDDD.BlazorClient.Services;
97

@@ -60,114 +58,4 @@ public async Task<FeedbackResponseDTO> SubmitClientSessionFeedback(SubmitSession
6058
var response = await _http.PostAsJsonAsync("Feedback/ClientSessionFeedback", feedbackDTO);
6159
return (await response.Content.ReadFromJsonAsync<FeedbackResponseDTO>())!;
6260
}
63-
}
64-
65-
public class FakePocketDDDApiService : IPocketDDDApiService
66-
{
67-
public Task<LoginResultDTO> Login(string name)
68-
{
69-
return Task.FromResult(new LoginResultDTO(name, Guid.NewGuid().ToString()));
70-
}
71-
72-
public void SetUserAuthToken(string token)
73-
{
74-
75-
}
76-
77-
public async Task<EventDataResponseDTO?> FetchLatestEventData(EventDataUpdateRequestDTO requestDTO)
78-
{
79-
if (requestDTO.Version == 1)
80-
{
81-
await Task.Delay(1000);
82-
return null;
83-
}
84-
85-
return
86-
new EventDataResponseDTO
87-
{
88-
Version = 1,
89-
TimeSlots = new[]
90-
{
91-
new TimeSlotDTO
92-
{
93-
Id = 1,
94-
From = new DateTimeOffset(2023, 4, 29, 8, 00, 0, TimeSpan.Zero),
95-
To = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
96-
Info = "Registration"
97-
},
98-
new TimeSlotDTO
99-
{
100-
Id = 2,
101-
From = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
102-
To = new DateTimeOffset(2023, 4, 29, 9, 0, 0, TimeSpan.Zero),
103-
Info = "Intro"
104-
},
105-
new TimeSlotDTO
106-
{
107-
Id = 3,
108-
From = new DateTimeOffset(2023, 4, 29, 9, 00, 0, TimeSpan.Zero),
109-
To = new DateTimeOffset(2023, 4, 29, 10, 00, 0, TimeSpan.Zero)
110-
},
111-
new TimeSlotDTO
112-
{
113-
Id = 4,
114-
From = new DateTimeOffset(2023, 4, 29, 10, 0, 0, TimeSpan.Zero),
115-
To = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
116-
Info = "Coffee"
117-
},
118-
new TimeSlotDTO
119-
{
120-
Id = 5,
121-
From = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
122-
To = new DateTimeOffset(2023, 4, 29, 11, 20, 0, TimeSpan.Zero)
123-
},
124-
},
125-
Tracks = new[]
126-
{
127-
new TrackDTO { Id = 1, Name = "Track 1", RoomName = "Room 1" },
128-
new TrackDTO { Id = 2, Name = "Track 2", RoomName = "Room 2" },
129-
new TrackDTO { Id = 3, Name = "Track 3", RoomName = "Room 3" }
130-
},
131-
Sessions = new[]
132-
{
133-
new SessionDTO
134-
{
135-
Id = 1,
136-
FullDescription = "Some full desk",
137-
Speaker = "Ross",
138-
TimeSlotId = 3,
139-
TrackId = 1,
140-
Title = "Blazor Session Management"
141-
},
142-
new SessionDTO
143-
{
144-
Id = 2,
145-
FullDescription = "Second session",
146-
Speaker = "Jim",
147-
TimeSlotId = 3,
148-
TrackId = 2,
149-
Title = "How to code"
150-
},
151-
new SessionDTO
152-
{
153-
Id = 3,
154-
FullDescription = "Third session",
155-
Speaker = "Bob",
156-
TimeSlotId = 5,
157-
TrackId = 2,
158-
Title = "Off by 1"
159-
},
160-
}
161-
};
162-
}
163-
164-
public Task<FeedbackResponseDTO> SubmitClientEventFeedback(SubmitEventFeedbackDTO feedbackDTO)
165-
{
166-
return Task.FromResult(new FeedbackResponseDTO { ClientId = feedbackDTO.ClientId, Score = 2 });
167-
}
168-
169-
public Task<FeedbackResponseDTO> SubmitClientSessionFeedback(SubmitSessionFeedbackDTO feedbackDTO)
170-
{
171-
return Task.FromResult(new FeedbackResponseDTO { ClientId = feedbackDTO.ClientId, Score = 3 });
172-
}
17361
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- Before running this script, ensure that FullDBScript.sql has been run to create the tables
2+
3+
-- Remove all the data
4+
delete [UserSessionFeedback]
5+
delete [UserEventFeedback]
6+
delete [Sessions]
7+
delete TimeSlots
8+
delete Tracks
9+
delete EventDetail
10+
11+
12+
GO
13+
14+
-- Reset the identity columns
15+
DBCC CHECKIDENT ('[Tracks]', RESEED, 0);
16+
DBCC CHECKIDENT ('[TimeSlots]', RESEED, 0);
17+
DBCC CHECKIDENT ('[Sessions]', RESEED, 0);
18+
19+
-- There is hardcoding to EventDetail ID 1 so we reset to 1 not 0
20+
DBCC CHECKIDENT ('[EventDetail]', RESEED, 1); -- Use if this is a brand new table that has never been used before
21+
--DBCC CHECKIDENT ('[EventDetail]', RESEED, 0); -- Use if this is an empty table that used to have rows
22+
23+
GO
24+
25+
-- Add 2025 Sessionize ID
26+
Insert into EventDetail
27+
values (1, '8oswqcwt')
28+
29+
GO

PocketDDD.Server/PocketDDD.Server.Model/Sessionize/ApiDTOs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class SessionizeEvent
5555

5656
public class Session
5757
{
58-
public int id { get; set; }
58+
public string id { get; set; }
5959
public string title { get; set; }
6060
public string description { get; set; }
6161
public DateTime startsAt { get; set; }

PocketDDD.Server/PocketDDD.Server.Services/SessionizeService.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Net.Http.Json;
66

77
namespace PocketDDD.Server.Services;
8+
89
public class SessionizeService
910
{
1011
private readonly HttpClient httpClient;
@@ -50,7 +51,8 @@ public async Task UpdateFromSessionize()
5051

5152
var dbTimeSlots = await dbContext.TimeSlots.ToListAsync();
5253
var sessionizeTimeSlots = sessionizeEvent.sessions
53-
.Select(x => (x.startsAt, x.endsAt))
54+
.Select(x => (x.startsAt, x.endsAt, x.isServiceSession,
55+
serviceSessionDetails: x.isServiceSession ? x.title : null))
5456
.Distinct()
5557
.ToList();
5658

@@ -64,7 +66,7 @@ public async Task UpdateFromSessionize()
6466
EventDetail = dbEvent,
6567
From = item.startsAt,
6668
To = item.endsAt,
67-
Info = null
69+
Info = item.isServiceSession ? item.serviceSessionDetails : null
6870
};
6971
dbContext.TimeSlots.Add(dbTimeSlot);
7072
}
@@ -80,12 +82,16 @@ public async Task UpdateFromSessionize()
8082

8183
foreach (var item in sessionizeEvent.sessions)
8284
{
83-
var dbSession = dbSessions.SingleOrDefault(x => x.SessionizeId == item.id);
85+
if (item.isServiceSession) continue;
86+
87+
var sessionizeId = int.Parse(item.id);
88+
89+
var dbSession = dbSessions.SingleOrDefault(x => x.SessionizeId == sessionizeId);
8490
if (dbSession == null)
8591
{
8692
dbSession = new Model.DBModel.Session
8793
{
88-
SessionizeId = item.id,
94+
SessionizeId = sessionizeId,
8995
EventDetail = dbEvent,
9096
SpeakerToken = Guid.NewGuid(),
9197
ShortDescription = ""
@@ -103,10 +109,13 @@ public async Task UpdateFromSessionize()
103109
await dbContext.SaveChangesAsync();
104110
}
105111

106-
private string GetSpeakers(List<PocketDDD.Server.Model.Sessionize.Speaker> speakers, List<string> speakerIds)
107-
=> speakerIds.Aggregate("", (acc, x) => acc + ", " + speakers.Single(s => s.id == x).fullName).Trim(',');
112+
private string GetSpeakers(List<Speaker> speakers, List<string> speakerIds)
113+
{
114+
return speakerIds.Aggregate("", (acc, x) => acc + ", " + speakers.Single(s => s.id == x).fullName).Trim(',');
115+
}
108116

109117
private TimeSlot GetTimeSlot(List<TimeSlot> timeSlots, DateTime startsAt, DateTime endsAt)
110-
=> timeSlots.Single(x => x.From == startsAt && x.To == endsAt);
111-
112-
}
118+
{
119+
return timeSlots.Single(x => x.From == startsAt && x.To == endsAt);
120+
}
121+
}
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

3-
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<Nullable>enable</Nullable>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<UserSecretsId>94f2b34d-f80b-4de4-ac9c-d0fb8e36fd07</UserSecretsId>
8-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<UserSecretsId>94f2b34d-f80b-4de4-ac9c-d0fb8e36fd07</UserSecretsId>
8+
</PropertyGroup>
99

10-
<ItemGroup>
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
12-
<PrivateAssets>all</PrivateAssets>
13-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14-
</PackageReference>
15-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
16-
</ItemGroup>
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
</PackageReference>
15+
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.15"/>
16+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
17+
</ItemGroup>
1718

18-
<ItemGroup>
19-
<ProjectReference Include="..\..\PocketDDD.Shared\PocketDDD.Shared.csproj" />
20-
<ProjectReference Include="..\PocketDDD.Server.DB\PocketDDD.Server.DB.csproj" />
21-
<ProjectReference Include="..\PocketDDD.Server.Model\PocketDDD.Server.Model.csproj" />
22-
<ProjectReference Include="..\PocketDDD.Server.Services\PocketDDD.Server.Services.csproj" />
23-
</ItemGroup>
19+
<ItemGroup>
20+
<ProjectReference Include="..\..\PocketDDD.Shared\PocketDDD.Shared.csproj"/>
21+
<ProjectReference Include="..\PocketDDD.Server.DB\PocketDDD.Server.DB.csproj"/>
22+
<ProjectReference Include="..\PocketDDD.Server.Model\PocketDDD.Server.Model.csproj"/>
23+
<ProjectReference Include="..\PocketDDD.Server.Services\PocketDDD.Server.Services.csproj"/>
24+
</ItemGroup>
2425

2526
</Project>

0 commit comments

Comments
 (0)