Skip to content

Commit

Permalink
added registerFamilyForEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
dillancagnetta committed Jan 28, 2025
1 parent 5d457b5 commit 2d2ecd9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ChurchManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChurchManager.Features.Hist
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChurchManager.Domain.Tests", "test\ChurchManager.Domain.Tests\ChurchManager.Domain.Tests.csproj", "{336595BB-943E-4B6F-984E-13FCB8B4F43D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChurchManager.Features.Events", "src\Features\ChurchManager.Features.Events\ChurchManager.Features.Events.csproj", "{0C6F1604-605E-4A1A-98F8-52D2D3939190}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -222,6 +224,10 @@ Global
{336595BB-943E-4B6F-984E-13FCB8B4F43D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{336595BB-943E-4B6F-984E-13FCB8B4F43D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{336595BB-943E-4B6F-984E-13FCB8B4F43D}.Release|Any CPU.Build.0 = Release|Any CPU
{0C6F1604-605E-4A1A-98F8-52D2D3939190}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C6F1604-605E-4A1A-98F8-52D2D3939190}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C6F1604-605E-4A1A-98F8-52D2D3939190}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C6F1604-605E-4A1A-98F8-52D2D3939190}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -257,6 +263,7 @@ Global
{72E00EBA-F609-4A76-9C0D-854DCA27D54C} = {D4173B5E-3368-41B7-A208-72DD77CE12C5}
{42FE2282-1494-4B7F-8FA1-53F04F8B573F} = {4E57F1DC-B09A-46B9-81A2-D6325F089A7C}
{336595BB-943E-4B6F-984E-13FCB8B4F43D} = {B40AA988-6333-4B1C-8C7C-3D8B140DBDE1}
{0C6F1604-605E-4A1A-98F8-52D2D3939190} = {4E57F1DC-B09A-46B9-81A2-D6325F089A7C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FFB97C3E-0578-455B-ABD1-9C774B9BDEAC}
Expand Down
1 change: 1 addition & 0 deletions src/API/ChurchManager.Api/ChurchManager.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<ProjectReference Include="..\..\Features\ChurchManager.Features.Common\ChurchManager.Features.Common.csproj" />
<ProjectReference Include="..\..\Features\ChurchManager.Features.Communication\ChurchManager.Features.Communication.csproj" />
<ProjectReference Include="..\..\Features\ChurchManager.Features.Discipleship\ChurchManager.Features.Discipleship.csproj" />
<ProjectReference Include="..\..\Features\ChurchManager.Features.Events\ChurchManager.Features.Events.csproj" />
<ProjectReference Include="..\..\Features\ChurchManager.Features.FollowUp\ChurchManager.Features.FollowUp.csproj" />
<ProjectReference Include="..\..\Features\ChurchManager.Features.Groups\ChurchManager.Features.Groups.csproj" />
<ProjectReference Include="..\..\Features\ChurchManager.Features.History\ChurchManager.Features.History.csproj" />
Expand Down
9 changes: 8 additions & 1 deletion src/API/ChurchManager.Api/Controllers/v1/EventsController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ChurchManager.Domain.Features.Events.Repositories;
using ChurchManager.Features.Events.Commands;
using ChurchManager.SharedKernel.Wrappers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -9,12 +10,18 @@ namespace ChurchManager.Api.Controllers.v1
[Authorize]
public class EventsController(IEventDbRepository dbRepository) : BaseApiController
{

[HttpGet("{eventId}")]
[AllowAnonymous]
public async Task<IActionResult> GetEventDetails(int eventId, CancellationToken token)
{
return Ok(new ApiResponse(await dbRepository.EventDetailsAsync(eventId, token)));
}

[HttpPost("{eventId}/register-for-event")]
[AllowAnonymous]
public async Task<IActionResult> RegisterForEvent([FromBody] RegisterFamilyForEventCommand command, CancellationToken token)
{
return Ok(await Mediator.Send(command, token));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<Import Project="..\..\Build\ChurchManager.Common.props" />
<ItemGroup>
<ProjectReference Include="..\..\Infrastructure\ChurchManager.Infrastructure\ChurchManager.Infrastructure.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using ChurchManager.SharedKernel.Wrappers;
using MediatR;

namespace ChurchManager.Features.Events.Commands;

public record RegisterFamilyForEventCommand(int EventId, IEnumerable<SelectedMember> SelectedMembers) : IRequest<ApiResponse>;

public record SelectedMember
{
public int PersonId { get; set; }
public bool IsSelected { get; set; }
public ChildInfo ChildInfo { get; set; }
public Dictionary<int, SessionPreference> SessionPreferences { get; set; }
}

public record ChildInfo
{
// Add properties as needed for child information
// For example:
// public string EmergencyContact { get; set; }
// public string AllergiesInfo { get; set; }
}

public record SessionPreference
{
public bool? AttendingOnline { get; set; }
public bool? AttendingInPerson { get; set; }
}

public class RegisterFamilyForEventHandler : IRequestHandler<RegisterFamilyForEventCommand, ApiResponse>
{
public Task<ApiResponse> Handle(RegisterFamilyForEventCommand command, CancellationToken ct)
{
return Task.FromResult(new ApiResponse {Succeeded = true, Message = "Registration successful!"});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using ChurchManager.Infrastructure;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace ChurchManager.Features.Events.Startup;

public class StartupApplication: IStartupApplication
{
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
}

public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
{
}

public int Priority => 101;
public bool BeforeConfigure => false;
}

0 comments on commit 2d2ecd9

Please sign in to comment.