Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using PocketDDD.Shared.API.RequestDTOs;
using PocketDDD.Shared.API.ResponseDTOs;

namespace PocketDDD.BlazorClient.Services;

public class FakePocketDDDApiService : IPocketDDDApiService
{
public Task<LoginResultDTO> Login(string name)
{
return Task.FromResult(new LoginResultDTO(name, Guid.NewGuid().ToString()));
}

public void SetUserAuthToken(string token)
{
}

public async Task<EventDataResponseDTO?> FetchLatestEventData(EventDataUpdateRequestDTO requestDTO)
{
if (requestDTO.Version == 1)
{
await Task.Delay(1000);
return null;
}

return
new EventDataResponseDTO
{
Version = 1,
TimeSlots = new[]
{
new TimeSlotDTO
{
Id = 1,
From = new DateTimeOffset(2023, 4, 29, 8, 00, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
Info = "Registration"
},
new TimeSlotDTO
{
Id = 2,
From = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 9, 0, 0, TimeSpan.Zero),
Info = "Intro"
},
new TimeSlotDTO
{
Id = 3,
From = new DateTimeOffset(2023, 4, 29, 9, 00, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 10, 00, 0, TimeSpan.Zero)
},
new TimeSlotDTO
{
Id = 4,
From = new DateTimeOffset(2023, 4, 29, 10, 0, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
Info = "Coffee"
},
new TimeSlotDTO
{
Id = 5,
From = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 11, 20, 0, TimeSpan.Zero)
}
},
Tracks = new[]
{
new TrackDTO { Id = 1, Name = "Track 1", RoomName = "Room 1" },
new TrackDTO { Id = 2, Name = "Track 2", RoomName = "Room 2" },
new TrackDTO { Id = 3, Name = "Track 3", RoomName = "Room 3" }
},
Sessions = new[]
{
new SessionDTO
{
Id = 1,
FullDescription = "Some full desk",
Speaker = "Ross",
TimeSlotId = 3,
TrackId = 1,
Title = "Blazor Session Management"
},
new SessionDTO
{
Id = 2,
FullDescription = "Second session",
Speaker = "Jim",
TimeSlotId = 3,
TrackId = 2,
Title = "How to code"
},
new SessionDTO
{
Id = 3,
FullDescription = "Third session",
Speaker = "Bob",
TimeSlotId = 5,
TrackId = 2,
Title = "Off by 1"
}
}
};
}

public Task<FeedbackResponseDTO> SubmitClientEventFeedback(SubmitEventFeedbackDTO feedbackDTO)
{
return Task.FromResult(new FeedbackResponseDTO { ClientId = feedbackDTO.ClientId, Score = 2 });
}

public Task<FeedbackResponseDTO> SubmitClientSessionFeedback(SubmitSessionFeedbackDTO feedbackDTO)
{
return Task.FromResult(new FeedbackResponseDTO { ClientId = feedbackDTO.ClientId, Score = 3 });
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Net;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using MudBlazor;
using PocketDDD.Shared.API.ResponseDTOs;
using PocketDDD.Shared.API.RequestDTOs;
using PocketDDD.Shared.API.ResponseDTOs;

namespace PocketDDD.BlazorClient.Services;

Expand Down Expand Up @@ -60,114 +58,4 @@ public async Task<FeedbackResponseDTO> SubmitClientSessionFeedback(SubmitSession
var response = await _http.PostAsJsonAsync("Feedback/ClientSessionFeedback", feedbackDTO);
return (await response.Content.ReadFromJsonAsync<FeedbackResponseDTO>())!;
}
}

public class FakePocketDDDApiService : IPocketDDDApiService
{
public Task<LoginResultDTO> Login(string name)
{
return Task.FromResult(new LoginResultDTO(name, Guid.NewGuid().ToString()));
}

public void SetUserAuthToken(string token)
{

}

public async Task<EventDataResponseDTO?> FetchLatestEventData(EventDataUpdateRequestDTO requestDTO)
{
if (requestDTO.Version == 1)
{
await Task.Delay(1000);
return null;
}

return
new EventDataResponseDTO
{
Version = 1,
TimeSlots = new[]
{
new TimeSlotDTO
{
Id = 1,
From = new DateTimeOffset(2023, 4, 29, 8, 00, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
Info = "Registration"
},
new TimeSlotDTO
{
Id = 2,
From = new DateTimeOffset(2023, 4, 29, 8, 30, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 9, 0, 0, TimeSpan.Zero),
Info = "Intro"
},
new TimeSlotDTO
{
Id = 3,
From = new DateTimeOffset(2023, 4, 29, 9, 00, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 10, 00, 0, TimeSpan.Zero)
},
new TimeSlotDTO
{
Id = 4,
From = new DateTimeOffset(2023, 4, 29, 10, 0, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
Info = "Coffee"
},
new TimeSlotDTO
{
Id = 5,
From = new DateTimeOffset(2023, 4, 29, 10, 20, 0, TimeSpan.Zero),
To = new DateTimeOffset(2023, 4, 29, 11, 20, 0, TimeSpan.Zero)
},
},
Tracks = new[]
{
new TrackDTO { Id = 1, Name = "Track 1", RoomName = "Room 1" },
new TrackDTO { Id = 2, Name = "Track 2", RoomName = "Room 2" },
new TrackDTO { Id = 3, Name = "Track 3", RoomName = "Room 3" }
},
Sessions = new[]
{
new SessionDTO
{
Id = 1,
FullDescription = "Some full desk",
Speaker = "Ross",
TimeSlotId = 3,
TrackId = 1,
Title = "Blazor Session Management"
},
new SessionDTO
{
Id = 2,
FullDescription = "Second session",
Speaker = "Jim",
TimeSlotId = 3,
TrackId = 2,
Title = "How to code"
},
new SessionDTO
{
Id = 3,
FullDescription = "Third session",
Speaker = "Bob",
TimeSlotId = 5,
TrackId = 2,
Title = "Off by 1"
},
}
};
}

public Task<FeedbackResponseDTO> SubmitClientEventFeedback(SubmitEventFeedbackDTO feedbackDTO)
{
return Task.FromResult(new FeedbackResponseDTO { ClientId = feedbackDTO.ClientId, Score = 2 });
}

public Task<FeedbackResponseDTO> SubmitClientSessionFeedback(SubmitSessionFeedbackDTO feedbackDTO)
{
return Task.FromResult(new FeedbackResponseDTO { ClientId = feedbackDTO.ClientId, Score = 3 });
}
}
29 changes: 29 additions & 0 deletions PocketDDD.Server/PocketDDD.Server.DB/Migrations/2025_SeedData.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- Before running this script, ensure that FullDBScript.sql has been run to create the tables

-- Remove all the data
delete [UserSessionFeedback]
delete [UserEventFeedback]
delete [Sessions]
delete TimeSlots
delete Tracks
delete EventDetail


GO

-- Reset the identity columns
DBCC CHECKIDENT ('[Tracks]', RESEED, 0);
DBCC CHECKIDENT ('[TimeSlots]', RESEED, 0);
DBCC CHECKIDENT ('[Sessions]', RESEED, 0);

-- There is hardcoding to EventDetail ID 1 so we reset to 1 not 0
DBCC CHECKIDENT ('[EventDetail]', RESEED, 1); -- Use if this is a brand new table that has never been used before
--DBCC CHECKIDENT ('[EventDetail]', RESEED, 0); -- Use if this is an empty table that used to have rows

GO

-- Add 2025 Sessionize ID
Insert into EventDetail
values (1, '8oswqcwt')

GO
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class SessionizeEvent

public class Session
{
public int id { get; set; }
public string id { get; set; }
public string title { get; set; }
public string description { get; set; }
public DateTime startsAt { get; set; }
Expand Down
27 changes: 18 additions & 9 deletions PocketDDD.Server/PocketDDD.Server.Services/SessionizeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Net.Http.Json;

namespace PocketDDD.Server.Services;

public class SessionizeService
{
private readonly HttpClient httpClient;
Expand Down Expand Up @@ -50,7 +51,8 @@ public async Task UpdateFromSessionize()

var dbTimeSlots = await dbContext.TimeSlots.ToListAsync();
var sessionizeTimeSlots = sessionizeEvent.sessions
.Select(x => (x.startsAt, x.endsAt))
.Select(x => (x.startsAt, x.endsAt, x.isServiceSession,
serviceSessionDetails: x.isServiceSession ? x.title : null))
.Distinct()
.ToList();

Expand All @@ -64,7 +66,7 @@ public async Task UpdateFromSessionize()
EventDetail = dbEvent,
From = item.startsAt,
To = item.endsAt,
Info = null
Info = item.isServiceSession ? item.serviceSessionDetails : null
};
dbContext.TimeSlots.Add(dbTimeSlot);
}
Expand All @@ -80,12 +82,16 @@ public async Task UpdateFromSessionize()

foreach (var item in sessionizeEvent.sessions)
{
var dbSession = dbSessions.SingleOrDefault(x => x.SessionizeId == item.id);
if (item.isServiceSession) continue;

var sessionizeId = int.Parse(item.id);

var dbSession = dbSessions.SingleOrDefault(x => x.SessionizeId == sessionizeId);
if (dbSession == null)
{
dbSession = new Model.DBModel.Session
{
SessionizeId = item.id,
SessionizeId = sessionizeId,
EventDetail = dbEvent,
SpeakerToken = Guid.NewGuid(),
ShortDescription = ""
Expand All @@ -103,10 +109,13 @@ public async Task UpdateFromSessionize()
await dbContext.SaveChangesAsync();
}

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

private TimeSlot GetTimeSlot(List<TimeSlot> timeSlots, DateTime startsAt, DateTime endsAt)
=> timeSlots.Single(x => x.From == startsAt && x.To == endsAt);

}
{
return timeSlots.Single(x => x.From == startsAt && x.To == endsAt);
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>94f2b34d-f80b-4de4-ac9c-d0fb8e36fd07</UserSecretsId>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>94f2b34d-f80b-4de4-ac9c-d0fb8e36fd07</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.15"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\PocketDDD.Shared\PocketDDD.Shared.csproj" />
<ProjectReference Include="..\PocketDDD.Server.DB\PocketDDD.Server.DB.csproj" />
<ProjectReference Include="..\PocketDDD.Server.Model\PocketDDD.Server.Model.csproj" />
<ProjectReference Include="..\PocketDDD.Server.Services\PocketDDD.Server.Services.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\PocketDDD.Shared\PocketDDD.Shared.csproj"/>
<ProjectReference Include="..\PocketDDD.Server.DB\PocketDDD.Server.DB.csproj"/>
<ProjectReference Include="..\PocketDDD.Server.Model\PocketDDD.Server.Model.csproj"/>
<ProjectReference Include="..\PocketDDD.Server.Services\PocketDDD.Server.Services.csproj"/>
</ItemGroup>

</Project>
Loading
Loading