-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
96 changed files
with
1,408 additions
and
2,300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26124.0 | ||
MinimumVisualStudioVersion = 15.0.26124.0 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphQL", "GraphQL\GraphQL.csproj", "{48385280-56F1-4937-9655-E6A79184740B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{48385280-56F1-4937-9655-E6A79184740B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Debug|x64.Build.0 = Debug|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Debug|x86.Build.0 = Debug|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Release|x64.ActiveCfg = Release|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Release|x64.Build.0 = Release|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Release|x86.ActiveCfg = Release|Any CPU | ||
{48385280-56F1-4937-9655-E6A79184740B}.Release|x86.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphQL", "GraphQL\GraphQL.csproj", "{D96823B9-86D3-4D54-A803-F1D43AEBE1FD}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{D96823B9-86D3-4D54-A803-F1D43AEBE1FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D96823B9-86D3-4D54-A803-F1D43AEBE1FD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D96823B9-86D3-4D54-A803-F1D43AEBE1FD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D96823B9-86D3-4D54-A803-F1D43AEBE1FD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using ConferencePlanner.GraphQL.Data; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace ConferencePlanner.GraphQL.Attendees; | ||
|
||
public static class AttendeeDataLoaders | ||
{ | ||
[DataLoader] | ||
public static async Task<IReadOnlyDictionary<int, Attendee>> AttendeeByIdAsync( | ||
IReadOnlyList<int> ids, | ||
ApplicationDbContext dbContext, | ||
CancellationToken cancellationToken) | ||
{ | ||
return await dbContext.Attendees | ||
.Where(a => ids.Contains(a.Id)) | ||
.ToDictionaryAsync(a => a.Id, cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace ConferencePlanner.GraphQL.Attendees; | ||
|
||
public sealed class AttendeeNotFoundException() : Exception("Attendee not found."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,56 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using ConferencePlanner.GraphQL.Common; | ||
using ConferencePlanner.GraphQL.Data; | ||
using HotChocolate; | ||
using HotChocolate.Types; | ||
using HotChocolate.Subscriptions; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace ConferencePlanner.GraphQL.Attendees; | ||
|
||
namespace ConferencePlanner.GraphQL.Attendees | ||
[MutationType] | ||
public static class AttendeeMutations | ||
{ | ||
[ExtendObjectType(Name = "Mutation")] | ||
public class AttendeeMutations | ||
public static async Task<Attendee> RegisterAttendeeAsync( | ||
RegisterAttendeeInput input, | ||
ApplicationDbContext dbContext, | ||
CancellationToken cancellationToken) | ||
{ | ||
[UseApplicationDbContext] | ||
public async Task<RegisterAttendeePayload> RegisterAttendeeAsync( | ||
RegisterAttendeeInput input, | ||
[ScopedService] ApplicationDbContext context, | ||
CancellationToken cancellationToken) | ||
var attendee = new Attendee | ||
{ | ||
var attendee = new Attendee | ||
{ | ||
FirstName = input.FirstName, | ||
LastName = input.LastName, | ||
UserName = input.UserName, | ||
EmailAddress = input.EmailAddress | ||
}; | ||
FirstName = input.FirstName, | ||
LastName = input.LastName, | ||
Username = input.Username, | ||
EmailAddress = input.EmailAddress | ||
}; | ||
|
||
context.Attendees.Add(attendee); | ||
dbContext.Attendees.Add(attendee); | ||
|
||
await context.SaveChangesAsync(cancellationToken); | ||
await dbContext.SaveChangesAsync(cancellationToken); | ||
|
||
return new RegisterAttendeePayload(attendee); | ||
} | ||
return attendee; | ||
} | ||
|
||
[UseApplicationDbContext] | ||
public async Task<CheckInAttendeePayload> CheckInAttendeeAsync( | ||
CheckInAttendeeInput input, | ||
[ScopedService] ApplicationDbContext context, | ||
[Service] ITopicEventSender eventSender, | ||
CancellationToken cancellationToken) | ||
{ | ||
Attendee attendee = await context.Attendees.FirstOrDefaultAsync( | ||
t => t.Id == input.AttendeeId, cancellationToken); | ||
public static async Task<Attendee> CheckInAttendeeAsync( | ||
CheckInAttendeeInput input, | ||
ApplicationDbContext dbContext, | ||
ITopicEventSender eventSender, | ||
CancellationToken cancellationToken) | ||
{ | ||
var attendee = await dbContext.Attendees.FirstOrDefaultAsync( | ||
a => a.Id == input.AttendeeId, | ||
cancellationToken); | ||
|
||
if (attendee is null) | ||
{ | ||
return new CheckInAttendeePayload( | ||
new UserError("Attendee not found.", "ATTENDEE_NOT_FOUND")); | ||
} | ||
if (attendee is null) | ||
{ | ||
throw new AttendeeNotFoundException(); | ||
} | ||
|
||
attendee.SessionsAttendees.Add( | ||
new SessionAttendee | ||
{ | ||
SessionId = input.SessionId | ||
}); | ||
attendee.SessionsAttendees.Add(new SessionAttendee { SessionId = input.SessionId }); | ||
|
||
await context.SaveChangesAsync(cancellationToken); | ||
await dbContext.SaveChangesAsync(cancellationToken); | ||
|
||
await eventSender.SendAsync( | ||
"OnAttendeeCheckedIn_" + input.SessionId, | ||
input.AttendeeId, | ||
cancellationToken); | ||
await eventSender.SendAsync( | ||
$"OnAttendeeCheckedIn_{input.SessionId}", | ||
input.AttendeeId, | ||
cancellationToken); | ||
|
||
return new CheckInAttendeePayload(attendee, input.SessionId); | ||
} | ||
return attendee; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using ConferencePlanner.GraphQL.Data; | ||
using ConferencePlanner.GraphQL.DataLoader; | ||
using HotChocolate; | ||
using HotChocolate.Types; | ||
using HotChocolate.Types.Relay; | ||
|
||
namespace ConferencePlanner.GraphQL.Attendees | ||
namespace ConferencePlanner.GraphQL.Attendees; | ||
|
||
[QueryType] | ||
public static class AttendeeQueries | ||
{ | ||
[ExtendObjectType(Name = "Query")] | ||
public class AttendeeQueries | ||
[UsePaging] | ||
public static IQueryable<Attendee> GetAttendees(ApplicationDbContext dbContext) | ||
{ | ||
[UseApplicationDbContext] | ||
[UsePaging] | ||
public IQueryable<Attendee> GetAttendees( | ||
[ScopedService] ApplicationDbContext context) => | ||
context.Attendees; | ||
return dbContext.Attendees.OrderBy(a => a.Username); | ||
} | ||
|
||
public Task<Attendee> GetAttendeeByIdAsync( | ||
[ID(nameof(Attendee))] int id, | ||
AttendeeByIdDataLoader attendeeById, | ||
CancellationToken cancellationToken) => | ||
attendeeById.LoadAsync(id, cancellationToken); | ||
[NodeResolver] | ||
public static async Task<Attendee> GetAttendeeByIdAsync( | ||
int id, | ||
AttendeeByIdDataLoader attendeeById, | ||
CancellationToken cancellationToken) | ||
{ | ||
return await attendeeById.LoadAsync(id, cancellationToken); | ||
} | ||
|
||
public async Task<IEnumerable<Attendee>> GetAttendeesByIdAsync( | ||
[ID(nameof(Attendee))] int[] ids, | ||
AttendeeByIdDataLoader attendeeById, | ||
CancellationToken cancellationToken) => | ||
await attendeeById.LoadAsync(ids, cancellationToken); | ||
public static async Task<IEnumerable<Attendee>> GetAttendeesByIdAsync( | ||
[ID<Attendee>] int[] ids, | ||
AttendeeByIdDataLoader attendeeById, | ||
CancellationToken cancellationToken) | ||
{ | ||
return await attendeeById.LoadAsync(ids, cancellationToken); | ||
} | ||
} | ||
} |
Oops, something went wrong.