beta 0.0.3

This commit is contained in:
Tomasi - Developing 2024-11-26 08:43:01 +01:00
parent 5f156ecd3c
commit 35e83c4735
323 changed files with 13779 additions and 571 deletions

2
.gitignore vendored
View File

@ -364,3 +364,5 @@ MigrationBackup/
FodyWeavers.xsd
/Api/appsettings.json
/Api/appsettings.Development.json
/Ui/src/environments/environment.development.ts
/Ui/src/environments/environment.ts

View File

@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "9.0.0",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
@ -10,15 +10,16 @@
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="8.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -10,8 +10,8 @@ namespace Api.Controllers.v1
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
//[Authorize]
public class AdmonitionsController(IAdmonitionRepository admonitionRepository, ILogger<AdmonitionsController> logger) : ControllerBase
[Authorize]
public class AdmonitionsController(IAdmonitionRepository admonitionRepository, IClaimTypeService claimTypeService, ILogger<AdmonitionsController> logger) : ControllerBase
{
[HttpGet]
public async Task<ActionResult<List<AdmonitionDto>>> GetAdmonitions(CancellationToken cancellationToken)
@ -80,7 +80,7 @@ namespace Api.Controllers.v1
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult =
await admonitionRepository.CreateAdmonitionAsync(createAdmonitionDto, cancellationToken);
await admonitionRepository.CreateAdmonitionAsync(createAdmonitionDto, claimTypeService.GetFullName(User), cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
@ -104,7 +104,7 @@ namespace Api.Controllers.v1
if (admonitionId != updateAdmonitionDto.Id) return Conflict(AdmonitionErrors.IdConflict);
var updateResult =
await admonitionRepository.UpdateAdmonitionAsync(updateAdmonitionDto, cancellationToken);
await admonitionRepository.UpdateAdmonitionAsync(updateAdmonitionDto, claimTypeService.GetFullName(User), cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)

View File

@ -11,7 +11,7 @@ namespace Api.Controllers.v1
[ApiController]
[ApiVersion("1.0")]
[Authorize]
public class AlliancesController(IAllianceRepository allianceRepository, ILogger<AlliancesController> logger) : ControllerBase
public class AlliancesController(IAllianceRepository allianceRepository, IClaimTypeService claimTypeService, ILogger<AlliancesController> logger) : ControllerBase
{
[HttpGet]
public async Task<ActionResult<List<AllianceDto>>> GetAlliances(CancellationToken cancellationToken)
@ -51,28 +51,6 @@ namespace Api.Controllers.v1
}
}
[HttpPost]
public async Task<ActionResult<AllianceDto>> CreateAlliance(CreateAllianceDto createAllianceDto,
CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult = await allianceRepository.CreateAllianceAsync(createAllianceDto, cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
: CreatedAtAction(nameof(GetAlliance), new { allianceId = createResult.Value.Id }, createResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("{allianceId:guid}")]
public async Task<ActionResult<AllianceDto>> UpdateAlliance(Guid allianceId, UpdateAllianceDto updateAllianceDto, CancellationToken cancellationToken)
{
@ -82,7 +60,7 @@ namespace Api.Controllers.v1
if (allianceId != updateAllianceDto.Id) return Conflict(AllianceErrors.IdConflict);
var updateResult = await allianceRepository.UpdateAllianceAsync(updateAllianceDto, cancellationToken);
var updateResult = await allianceRepository.UpdateAllianceAsync(updateAllianceDto, claimTypeService.GetFullName(User), cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)

View File

@ -14,18 +14,41 @@ namespace Api.Controllers.v1
{
[AllowAnonymous]
[HttpPost("[action]")]
public async Task<ActionResult<LoginResponseDto>> Register(RegisterRequestDto registerRequestDto, CancellationToken cancellationToken)
public async Task<ActionResult<bool>> SignUp(SignUpRequestDto signUpRequestDto, CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var registerResult =
await authenticationRepository.RegisterToApplicationAsync(registerRequestDto, cancellationToken);
await authenticationRepository.RegisterToApplicationAsync(signUpRequestDto, cancellationToken);
return registerResult.IsFailure
? BadRequest(registerResult.Error)
: Ok(registerResult.Value);
: Ok(true);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[AllowAnonymous]
[HttpPost("[action]")]
public async Task<ActionResult<bool>> RegisterUser(RegisterUserDto registerUserDto,
CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var registerResult =
await authenticationRepository.RegisterUserAsync(registerUserDto, cancellationToken);
return registerResult.IsFailure
? BadRequest(registerResult.Error)
: Ok(true);
}
catch (Exception e)
{
@ -54,5 +77,120 @@ namespace Api.Controllers.v1
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[AllowAnonymous]
[HttpPost("[action]")]
public async Task<ActionResult<bool>> ResendConfirmationEmail(
EmailConfirmationRequestDto emailConfirmationRequestDto, CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var resendConfirmationEmailResult =
await authenticationRepository.ResendConfirmationEmailAsync(emailConfirmationRequestDto);
return resendConfirmationEmailResult.IsFailure
? BadRequest(resendConfirmationEmailResult.Error)
: Ok(true);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[AllowAnonymous]
[HttpPost("[action]")]
public async Task<ActionResult<bool>> ConfirmEmail(ConfirmEmailRequestDto confirmEmailRequestDto, CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var resendConfirmationEmailResult =
await authenticationRepository.EmailConfirmationAsync(confirmEmailRequestDto);
return resendConfirmationEmailResult.IsFailure
? BadRequest(resendConfirmationEmailResult.Error)
: Ok(true);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost("[action]")]
public async Task<ActionResult<bool>> InviteUser(InviteUserDto inviteUserDto,
CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var inviteUserResult = await authenticationRepository.InviteUserAsync(inviteUserDto, cancellationToken);
if (inviteUserResult.IsFailure) return BadRequest(inviteUserResult.Error);
return Ok(true);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[AllowAnonymous]
[HttpPost("[action]")]
public async Task<ActionResult<bool>> ForgotPassword(ForgotPasswordDto forgotPasswordDto,
CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var forgotPasswordResponse = await authenticationRepository.ForgotPasswordAsync(forgotPasswordDto);
if (forgotPasswordResponse.IsFailure)
{
logger.LogWarning(forgotPasswordResponse.Error.Name);
}
return Ok(true);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[AllowAnonymous]
[HttpPost("[action]")]
public async Task<ActionResult<bool>> ResetPassword(ResetPasswordDto resetPasswordDto,
CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
if (resetPasswordDto.Password != resetPasswordDto.ConfirmPassword)
return BadRequest("Reset password failed");
var resetPasswordResult = await authenticationRepository.ResetPasswordAsync(resetPasswordDto);
return resetPasswordResult.IsFailure
? BadRequest(resetPasswordResult.Error)
: Ok(true);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
}

View File

@ -0,0 +1,143 @@
using Application.DataTransferObjects.CustomEvent;
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Authorize]
public class CustomEventsController(ICustomEventRepository customEventRepository, IClaimTypeService claimTypeService, ILogger<CustomEventsController> logger) : ControllerBase
{
[HttpGet("{customEventId:guid}")]
public async Task<ActionResult<CustomEventDto>> GetCustomEvent(Guid customEventId,
CancellationToken cancellationToken)
{
try
{
var customEventResult =
await customEventRepository.GetCustomEventAsync(customEventId, cancellationToken);
return customEventResult.IsFailure
? BadRequest(customEventResult.Error)
: Ok(customEventResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<CustomEventDto>>> GetAllianceCustomEvents(Guid allianceId,
[FromQuery] int take, CancellationToken cancellationToken)
{
try
{
var allianceCustomEventsResult =
await customEventRepository.GetAllianceCustomEventsAsync(allianceId, take, cancellationToken);
if (allianceCustomEventsResult.IsFailure) return BadRequest(allianceCustomEventsResult.Error);
return allianceCustomEventsResult.Value.Count > 0
? Ok(allianceCustomEventsResult.Value)
: NoContent();
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("[action]/{customEventId:guid}")]
public async Task<ActionResult<CustomEventDetailDto>> GetCustomEventDetail(Guid customEventId,
CancellationToken cancellationToken)
{
try
{
var customEventDetailResult =
await customEventRepository.GetCustomEventDetailAsync(customEventId, cancellationToken);
return customEventDetailResult.IsFailure
? BadRequest(customEventDetailResult.Error)
: Ok(customEventDetailResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost]
public async Task<ActionResult<CustomEventDto>> CreateCustomEvent(CreateCustomEventDto createCustomEventDto,
CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult = await customEventRepository.CreateCustomEventAsync(createCustomEventDto,
claimTypeService.GetFullName(User), cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
: CreatedAtAction(nameof(GetCustomEvent), new { customEventId = createResult.Value.Id },
createResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("{customEventId:guid}")]
public async Task<ActionResult<CustomEventDto>> UpdateCustomEvent(Guid customEventId,
UpdateCustomEventDto updateCustomEventDto, CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
if (updateCustomEventDto.Id != customEventId) return Conflict(CustomEventErrors.IdConflict);
var updateResult = await customEventRepository.UpdateCustomEventAsync(updateCustomEventDto,
claimTypeService.GetFullName(User), cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)
: Ok(updateResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpDelete("{customEventId:guid}")]
public async Task<ActionResult<bool>> DeleteCustomEvent(Guid customEventId, CancellationToken cancellationToken)
{
try
{
var deleteResult = await customEventRepository.DeleteCustomEventAsync(customEventId, cancellationToken);
return deleteResult.IsFailure
? BadRequest(deleteResult.Error)
: Ok(deleteResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
}

View File

@ -0,0 +1,111 @@
using Application.DataTransferObjects.DesertStormParticipants;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Authorize]
public class DesertStormParticipantsController(IDesertStormParticipantRepository desertStormParticipantRepository, ILogger<DesertStormParticipantsController> logger) : ControllerBase
{
[HttpGet("{desertStormParticipantId:guid}")]
public async Task<ActionResult<DesertStormParticipantDto>> GetDesertStormParticipant(
Guid desertStormParticipantId, CancellationToken cancellationToken)
{
try
{
var desertStormParticipantResult =
await desertStormParticipantRepository.GetDesertStormParticipantAsync(desertStormParticipantId,
cancellationToken);
return desertStormParticipantResult.IsFailure
? BadRequest(desertStormParticipantResult.Error)
: Ok(desertStormParticipantResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("Player/{playerId:guid}")]
public async Task<ActionResult<List<DesertStormParticipantDto>>> GetPlayerDesertStormParticipants(
Guid playerId, [FromQuery] int last,
CancellationToken cancellationToken)
{
try
{
var desertStormPlayerParticipatedResult =
await desertStormParticipantRepository.GetPlayerDesertStormParticipantsAsync(playerId, last,
cancellationToken);
if (desertStormPlayerParticipatedResult.IsFailure)
return BadRequest(desertStormPlayerParticipatedResult.Error);
return desertStormPlayerParticipatedResult.Value.Count > 0
? Ok(desertStormPlayerParticipatedResult.Value)
: NoContent();
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost]
public async Task<IActionResult> InsertDesertStormParticipant(
List<CreateDesertStormParticipantDto> createDesertStormParticipantsDto, CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult =
await desertStormParticipantRepository.InsertDesertStormParticipantAsync(
createDesertStormParticipantsDto, cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
: StatusCode(StatusCodes.Status201Created);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("{desertStormParticipantId:guid}")]
public async Task<ActionResult<DesertStormParticipantDto>> UpdateMarshalGuardParticipant(
Guid desertStormParticipantId,
UpdateDesertStormParticipantDto updateDesertStormParticipantDto, CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
if (desertStormParticipantId != updateDesertStormParticipantDto.Id)
return Conflict(new Error("",""));
var updateResult =
await desertStormParticipantRepository.UpdateDesertStormParticipantAsync(
updateDesertStormParticipantDto, cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)
: Ok(updateResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
}

View File

@ -2,6 +2,7 @@
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
@ -9,8 +10,8 @@ namespace Api.Controllers.v1
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
//[Authorize]
public class DesertStormsController(IDesertStormRepository desertStormRepository, ILogger<DesertStormsController> logger) : ControllerBase
[Authorize]
public class DesertStormsController(IDesertStormRepository desertStormRepository, IClaimTypeService claimTypeService, ILogger<DesertStormsController> logger) : ControllerBase
{
[HttpGet("{desertStormId:guid}")]
public async Task<ActionResult<DesertStormDto>> GetDesertStorm(Guid desertStormId,
@ -32,20 +33,40 @@ namespace Api.Controllers.v1
}
}
[HttpGet("Player/{playerId:guid}")]
public async Task<ActionResult<List<DesertStormDto>>> GetPlayerDesertStorms(Guid playerId,
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<DesertStormDto>>> GetAllianceDesertStorms(Guid allianceId,
[FromQuery] int take, CancellationToken cancellationToken)
{
try
{
var allianceDesertStormsResult =
await desertStormRepository.GetAllianceDesertStormsAsync(allianceId, take, cancellationToken);
if (allianceDesertStormsResult.IsFailure) return BadRequest(allianceDesertStormsResult.Error);
return allianceDesertStormsResult.Value.Count > 0
? Ok(allianceDesertStormsResult.Value)
: NoContent();
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("[action]/{desertStormId:guid}")]
public async Task<ActionResult<DesertStormDetailDto>> GetDesertStormDetail(Guid desertStormId,
CancellationToken cancellationToken)
{
try
{
var playerDesertStormsResult =
await desertStormRepository.GetPlayerDesertStormsAsync(playerId, cancellationToken);
var desertStormDetailResult =
await desertStormRepository.GetDesertStormDetailAsync(desertStormId, cancellationToken);
if (playerDesertStormsResult.IsFailure) return BadRequest(playerDesertStormsResult.Error);
return playerDesertStormsResult.Value.Count > 0
? Ok(playerDesertStormsResult.Value)
: NoContent();
return desertStormDetailResult.IsFailure
? BadRequest(desertStormDetailResult.Error)
: Ok(desertStormDetailResult.Value);
}
catch (Exception e)
{
@ -63,7 +84,7 @@ namespace Api.Controllers.v1
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult =
await desertStormRepository.CreateDesertStormAsync(createDesertStormDto, cancellationToken);
await desertStormRepository.CreateDesertStormAsync(createDesertStormDto, claimTypeService.GetFullName(User), cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
@ -88,7 +109,7 @@ namespace Api.Controllers.v1
if (desertStormId != updateDesertStormDto.Id) return Conflict(DesertStormErrors.IdConflict);
var updateResult =
await desertStormRepository.UpdateDesertStormAsync(updateDesertStormDto, cancellationToken);
await desertStormRepository.UpdateDesertStormAsync(updateDesertStormDto, claimTypeService.GetFullName(User), cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)

View File

@ -0,0 +1,106 @@
using Application.DataTransferObjects.MarshalGuardParticipant;
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Authorize]
public class MarshalGuardParticipantsController(IMarshalGuardParticipantRepository marshalGuardParticipantRepository, ILogger<MarshalGuardParticipantsController> logger) : ControllerBase
{
[HttpGet("{marshalGuardParticipantId:guid}")]
public async Task<ActionResult<MarshalGuardParticipantDto>> GetMarshalGuardParticipant(
Guid marshalGuardParticipantId, CancellationToken cancellationToken)
{
try
{
var marshalGuardParticipantResult =
await marshalGuardParticipantRepository.GetMarshalGuardParticipantAsync(marshalGuardParticipantId,
cancellationToken);
return marshalGuardParticipantResult.IsFailure
? BadRequest(marshalGuardParticipantResult.Error)
: Ok(marshalGuardParticipantResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("Player/{playerId:guid}")]
public async Task<ActionResult<List<MarshalGuardParticipantDto>>> GetPlayerMarshalGuardsParticipants(Guid playerId, [FromQuery] int last,
CancellationToken cancellationToken)
{
try
{
var numberOfParticipationResult =
await marshalGuardParticipantRepository.GetPlayerMarshalParticipantsAsync(playerId, last,
cancellationToken);
return numberOfParticipationResult.IsFailure
? BadRequest(numberOfParticipationResult.Error)
: Ok(numberOfParticipationResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost]
public async Task<IActionResult> InsertMarshalGuardParticipant(
List<CreateMarshalGuardParticipantDto> createMarshalGuardParticipantsDto, CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult =
await marshalGuardParticipantRepository.InsertMarshalGuardParticipantAsync(
createMarshalGuardParticipantsDto, cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
: StatusCode(StatusCodes.Status201Created);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("{marshalGuardParticipantId:guid}")]
public async Task<ActionResult<MarshalGuardParticipantDto>> UpdateMarshalGuardParticipant(Guid marshalGuardParticipantId,
UpdateMarshalGuardParticipantDto updateMarshalGuardParticipantDto, CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
if (marshalGuardParticipantId != updateMarshalGuardParticipantDto.Id)
return Conflict(MarshalGuardErrors.IdConflict);
var updateResult =
await marshalGuardParticipantRepository.UpdateMarshalGuardParticipantAsync(
updateMarshalGuardParticipantDto, cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)
: Ok(updateResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
}

View File

@ -2,6 +2,7 @@
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
@ -9,8 +10,8 @@ namespace Api.Controllers.v1
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
//[Authorize]
public class MarshalGuardsController(IMarshalGuardRepository marshalGuardRepository, ILogger<MarshalGuardsController> logger) : ControllerBase
[Authorize]
public class MarshalGuardsController(IMarshalGuardRepository marshalGuardRepository, IClaimTypeService claimTypeService, ILogger<MarshalGuardsController> logger) : ControllerBase
{
[HttpGet("{marshalGuardId:guid}")]
public async Task<ActionResult<MarshalGuardDto>> GetMarshalGuard(Guid marshalGuardId,
@ -32,19 +33,19 @@ namespace Api.Controllers.v1
}
}
[HttpGet("Player/{playerId:guid}")]
public async Task<ActionResult<List<MarshalGuardDto>>> GetPlayerMarshalGuards(Guid playerId,
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<MarshalGuardDto>>> GetAllianceMarshalGuards(Guid allianceId, [FromQuery] int take,
CancellationToken cancellationToken)
{
try
{
var playerMarshalGuardsResult =
await marshalGuardRepository.GetPlayerMarshalGuardsAsync(playerId, cancellationToken);
var allianceMarshalGuardsResult =
await marshalGuardRepository.GetAllianceMarshalGuardsAsync(allianceId, take, cancellationToken);
if (playerMarshalGuardsResult.IsFailure) return BadRequest(playerMarshalGuardsResult.Error);
if (allianceMarshalGuardsResult.IsFailure) return BadRequest(allianceMarshalGuardsResult.Error);
return playerMarshalGuardsResult.Value.Count > 0
? Ok(playerMarshalGuardsResult.Value)
return allianceMarshalGuardsResult.Value.Count > 0
? Ok(allianceMarshalGuardsResult.Value)
: NoContent();
}
catch (Exception e)
@ -54,6 +55,27 @@ namespace Api.Controllers.v1
}
}
[HttpGet("[action]/{marshalGuardId:guid}")]
public async Task<ActionResult<MarshalGuardDetailDto>> GetMarshalGuardDetail(Guid marshalGuardId,
CancellationToken cancellationToken)
{
try
{
var marshalGuardDetailResult =
await marshalGuardRepository.GetMarshalGuardDetailAsync(marshalGuardId, cancellationToken);
return marshalGuardDetailResult.IsFailure
? BadRequest(marshalGuardDetailResult.Error)
: Ok(marshalGuardDetailResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost]
public async Task<ActionResult<MarshalGuardDto>> CreateMarshalGuard(CreateMarshalGuardDto createMarshalGuardDto,
CancellationToken cancellationToken)
@ -63,17 +85,17 @@ namespace Api.Controllers.v1
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult =
await marshalGuardRepository.CreateMarshalGuardAsync(createMarshalGuardDto, cancellationToken);
await marshalGuardRepository.CreateMarshalGuardsAsync(createMarshalGuardDto, claimTypeService.GetFullName(User), cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
: CreatedAtAction(nameof(GetMarshalGuard), new { marshalGuardId = createResult.Value.Id },
createResult.Value);
: CreatedAtAction(nameof(GetMarshalGuard),
new { marshalGuardId = createResult.Value.Id}, createResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError); ;
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
@ -83,12 +105,12 @@ namespace Api.Controllers.v1
{
try
{
if (ModelState.IsValid) return UnprocessableEntity(ModelState);
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
if (marshalGuardId != updateMarshalGuardDto.Id) return Conflict(MarshalGuardErrors.IdConflict);
var updateResult =
await marshalGuardRepository.UpdateMarshalGuardAsync(updateMarshalGuardDto, cancellationToken);
await marshalGuardRepository.UpdateMarshalGuardAsync(updateMarshalGuardDto, claimTypeService.GetFullName(User), cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)

View File

@ -2,6 +2,7 @@
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
@ -9,8 +10,8 @@ namespace Api.Controllers.v1
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
//[Authorize]
public class NotesController(INoteRepository noteRepository, ILogger<NotesController> logger) : ControllerBase
[Authorize]
public class NotesController(INoteRepository noteRepository, IClaimTypeService claimTypeService, ILogger<NotesController> logger) : ControllerBase
{
[HttpGet("{noteId:guid}")]
public async Task<ActionResult<NoteDto>> GetNote(Guid noteId, CancellationToken cancellationToken)
@ -59,7 +60,7 @@ namespace Api.Controllers.v1
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult = await noteRepository.CreateNoteAsync(createNoteDto, cancellationToken);
var createResult = await noteRepository.CreateNoteAsync(createNoteDto, claimTypeService.GetFullName(User), cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
@ -82,7 +83,7 @@ namespace Api.Controllers.v1
if (noteId != updateNoteDto.Id) return Conflict(NoteErrors.IdConflict);
var updateResult = await noteRepository.UpdateNoteAsync(updateNoteDto, cancellationToken);
var updateResult = await noteRepository.UpdateNoteAsync(updateNoteDto, claimTypeService.GetFullName(User), cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)

View File

@ -2,6 +2,7 @@
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -10,8 +11,8 @@ namespace Api.Controllers.v1
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
//[Authorize]
public class PlayersController(IPlayerRepository playerRepository, ILogger<PlayersController> logger) : ControllerBase
[Authorize]
public class PlayersController(IPlayerRepository playerRepository, IClaimTypeService claimTypeService, ILogger<PlayersController> logger) : ControllerBase
{
[HttpGet("{playerId:guid}")]
public async Task<ActionResult<PlayerDto>> GetPlayer(Guid playerId, CancellationToken cancellationToken)
@ -61,7 +62,7 @@ namespace Api.Controllers.v1
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult = await playerRepository.CreatePlayerAsync(createPlayerDto, cancellationToken);
var createResult = await playerRepository.CreatePlayerAsync(createPlayerDto, claimTypeService.GetFullName(User), cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
@ -83,7 +84,7 @@ namespace Api.Controllers.v1
if (playerId != updatePlayerDto.Id) return Conflict(PlayerErrors.IdConflict);
var updateResult = await playerRepository.UpdatePlayerAsync(updatePlayerDto, cancellationToken);
var updateResult = await playerRepository.UpdatePlayerAsync(updatePlayerDto, claimTypeService.GetFullName(User), cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)

View File

@ -0,0 +1,35 @@
using Application.DataTransferObjects.Rank;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Authorize]
public class RanksController(IRankRepository rankRepository, ILogger<RanksController> logger) : ControllerBase
{
[HttpGet]
public async Task<ActionResult<List<RankDto>>> GetRanks(CancellationToken cancellationToken)
{
try
{
var ranksResult = await rankRepository.GetRanksAsync(cancellationToken);
if (ranksResult.IsFailure) return BadRequest(ranksResult.Error);
return ranksResult.Value.Count > 0
? Ok(ranksResult.Value)
: NoContent();
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
}

View File

@ -0,0 +1,119 @@
using Application.DataTransferObjects.User;
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Authorize]
public class UsersController(IUserRepository userRepository, ILogger<UsersController> logger) : ControllerBase
{
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<UserDto>>> GetAllianceUsers(Guid allianceId,
CancellationToken cancellationToken)
{
try
{
var allianceUsersResult = await userRepository.GetAllianceUsersAsync(allianceId, cancellationToken);
if (allianceUsersResult.IsFailure) return BadRequest(allianceUsersResult.Error);
return allianceUsersResult.Value.Count > 0
? Ok(allianceUsersResult.Value)
: NoContent();
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpGet("{userId:guid}")]
public async Task<ActionResult<UserDto>> GetUser(Guid userId, CancellationToken cancellationToken)
{
try
{
var userResult = await userRepository.GetUserAsync(userId, cancellationToken);
return userResult.IsFailure
? BadRequest(userResult.Error)
: Ok(userResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPut("{userId:guid}")]
public async Task<ActionResult<UserDto>> UpdateUser(Guid userId, UpdateUserDto updateUserDto,
CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
if (userId != updateUserDto.Id) return Conflict(UserErrors.IdConflict);
var updateResult = await userRepository.UpdateUserAsync(updateUserDto, cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)
: Ok(updateResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost("[action]")]
public async Task<ActionResult<bool>> ChangeUserPassword(ChangePasswordDto changePasswordDto,
CancellationToken cancellationToken)
{
try
{
if (changePasswordDto.NewPassword != changePasswordDto.ConfirmPassword)
return BadRequest(UserErrors.ConfirmPasswordNotMatch);
var changePasswordResult =
await userRepository.ChangeUserPasswordAsync(changePasswordDto, cancellationToken);
return changePasswordResult.IsFailure
? BadRequest(changePasswordResult.Error)
: Ok(true);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpDelete("{userId:guid}")]
public async Task<ActionResult<bool>> DeleteUser(Guid userId, CancellationToken cancellationToken)
{
try
{
var deleteResult = await userRepository.DeleteUserAsync(userId, cancellationToken);
return deleteResult.IsFailure
? BadRequest(deleteResult.Error)
: Ok(true);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
}

View File

@ -0,0 +1,40 @@
using Application.DataTransferObjects.VsDuelParticipant;
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Authorize]
public class VsDuelParticipantsController(IVsDuelParticipantRepository vsDuelParticipantRepository, ILogger<VsDuelParticipantsController> logger) : ControllerBase
{
[HttpPut("{vsDuelParticipantId:guid}")]
public async Task<ActionResult<VsDuelParticipantDto>> UpdateVsDuelParticipant(Guid vsDuelParticipantId, VsDuelParticipantDto vsDuelParticipantDto, CancellationToken cancellationToken)
{
try
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
if (vsDuelParticipantId != vsDuelParticipantDto.Id) return Conflict(VsDuelParticipantErrors.IdConflict);
var updateResult =
await vsDuelParticipantRepository.UpdateVsDuelParticipant(vsDuelParticipantDto, cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)
: Ok(updateResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
}

View File

@ -2,6 +2,7 @@
using Application.Errors;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
@ -9,8 +10,8 @@ namespace Api.Controllers.v1
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
//[Authorize]
public class VsDuelsController(IVsDuelRepository vsDuelRepository, ILogger<VsDuelsController> logger) : ControllerBase
[Authorize]
public class VsDuelsController(IVsDuelRepository vsDuelRepository, IClaimTypeService claimTypeService, ILogger<VsDuelsController> logger) : ControllerBase
{
[HttpGet("{vsDuelId:guid}")]
public async Task<ActionResult<VsDuelDto>> GetVsDuel(Guid vsDuelId, CancellationToken cancellationToken)
@ -30,18 +31,19 @@ namespace Api.Controllers.v1
}
}
[HttpGet("Player/{playerId:guid}")]
public async Task<ActionResult<List<VsDuelDto>>> GetPlayerVsDuels(Guid playerId,
[HttpGet("Alliance/{allianceId:guid}")]
public async Task<ActionResult<List<VsDuelDto>>> GetAllianceVsDuels(Guid allianceId, [FromQuery] int take,
CancellationToken cancellationToken)
{
try
{
var playerVsDuelsResult = await vsDuelRepository.GetPlayerVsDuelsAsync(playerId, cancellationToken);
var allianceVsDuelsResult =
await vsDuelRepository.GetAllianceVsDuelsAsync(allianceId, take, cancellationToken);
if (playerVsDuelsResult.IsFailure) return BadRequest(playerVsDuelsResult.Error);
if (allianceVsDuelsResult.IsFailure) return BadRequest(allianceVsDuelsResult.Error);
return playerVsDuelsResult.Value.Count > 0
? Ok(playerVsDuelsResult.Value)
return allianceVsDuelsResult.Value.Count > 0
? Ok(allianceVsDuelsResult.Value)
: NoContent();
}
catch (Exception e)
@ -51,6 +53,25 @@ namespace Api.Controllers.v1
}
}
[HttpGet("[action]/{vsDuelId:guid}")]
public async Task<ActionResult<VsDuelDetailDto>> GetDetailVsDuel(Guid vsDuelId, CancellationToken cancellationToken)
{
try
{
var vsDuelDetailResult = await vsDuelRepository.GetVsDuelDetailAsync(vsDuelId, cancellationToken);
return vsDuelDetailResult.IsFailure
? BadRequest(vsDuelDetailResult.Error)
: Ok(vsDuelDetailResult.Value);
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[HttpPost]
public async Task<ActionResult<VsDuelDto>> CreateVsDuel(CreateVsDuelDto createVsDuelDto,
CancellationToken cancellationToken)
@ -59,7 +80,7 @@ namespace Api.Controllers.v1
{
if (!ModelState.IsValid) return UnprocessableEntity(ModelState);
var createResult = await vsDuelRepository.CreateVsDuelAsync(createVsDuelDto, cancellationToken);
var createResult = await vsDuelRepository.CreateVsDuelAsync(createVsDuelDto, claimTypeService.GetFullName(User), cancellationToken);
return createResult.IsFailure
? BadRequest(createResult.Error)
@ -82,7 +103,7 @@ namespace Api.Controllers.v1
if (vsDuelId != updateVsDuelDto.Id) return Conflict(VsDuelErrors.IdConflict);
var updateResult = await vsDuelRepository.UpdateVsDuelAsync(updateVsDuelDto, cancellationToken);
var updateResult = await vsDuelRepository.UpdateVsDuelAsync(updateVsDuelDto, claimTypeService.GetFullName(User), cancellationToken);
return updateResult.IsFailure
? BadRequest(updateResult.Error)

View File

@ -6,6 +6,7 @@ using Database;
using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Serilog;
using Utilities.Classes;
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
@ -32,11 +33,18 @@ try
builder.Services.ConfigureAndAddCors();
builder.Services.ConfigureAndAddHealthChecks(builder.Configuration);
builder.Services.AddOptions<EmailConfiguration>()
.BindConfiguration("EmailSettings")
.ValidateDataAnnotations()
.ValidateOnStart();
var jwtSection = builder.Configuration.GetRequiredSection("Jwt");
builder.Services.ConfigureAndAddAuthentication(jwtSection);
var app = builder.Build();
app.UseStaticFiles();
app.UseDefaultFiles();
app.UseSwagger();
app.UseSwaggerUI();
@ -57,6 +65,8 @@ try
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.MapFallbackToFile("index.html");
app.Run();
}
catch (Exception e)

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
@ -9,12 +9,15 @@
<ItemGroup>
<Folder Include="DataTransferObjects\Alliance\" />
<Folder Include="Classes\" />
<Folder Include="DataTransferObjects\MarshalGuardParticipant\" />
<Folder Include="DataTransferObjects\CustomEventParticipant\" />
<Folder Include="DataTransferObjects\Rank\" />
<Folder Include="DataTransferObjects\Note\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -3,6 +3,8 @@ using Application.Interfaces;
using Application.Repositories;
using Application.Services;
using Microsoft.Extensions.DependencyInjection;
using Utilities.Interfaces;
using Utilities.Services;
namespace Application;
@ -20,8 +22,17 @@ public static class ApplicationDependencyInjection
services.AddScoped<IPlayerRepository, PlayerRepository>();
services.AddScoped<IVsDuelRepository, VsDuelRepository>();
services.AddScoped<IAuthenticationRepository, AuthenticationRepository>();
services.AddScoped<IRankRepository, RankRepository>();
services.AddScoped<ICustomEventRepository, CustomEventRepository>();
services.AddScoped<IMarshalGuardParticipantRepository, MarshalGuardParticipantRepository>();
services.AddScoped<IVsDuelParticipantRepository, VsDuelParticipantRepository>();
services.AddScoped<IUserRepository, UserRepository>();
services.AddScoped<IDesertStormParticipantRepository, DesertStormParticipantRepository>();
services.AddTransient<IJwtService, JwtService>();
services.AddTransient<IClaimTypeService, ClaimTypeService>();
services.AddTransient<IEmailService, EmailService>();
return services;
}

View File

@ -0,0 +1,8 @@
namespace Application.Classes;
public class EmailContent
{
public required string Subject { get; set; }
public required string Content { get; set; }
}

View File

@ -6,5 +6,13 @@ public class AdmonitionDto
public required string Reason { get; set; }
public DateTime CreatedOn { get; set; }
public required string CreatedBy { get; set; }
public Guid PlayerId { get; set; }
public DateTime? ModifiedOn { get; set; }
public string? ModifiedBy { get; set; }
}

View File

@ -11,4 +11,7 @@ public class UpdateAdmonitionDto
[Required]
[MaxLength(250)]
public required string Reason { get; set; }
[Required]
public Guid PlayerId { get; set; }
}

View File

@ -1,4 +1,6 @@
namespace Application.DataTransferObjects.Alliance;
using System.Dynamic;
namespace Application.DataTransferObjects.Alliance;
public class AllianceDto
{
@ -9,4 +11,10 @@ public class AllianceDto
public required string Name { get; set; }
public required string Abbreviation { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime? ModifiedOn { get; set; }
public string? ModifiedBy { get; set; }
}

View File

@ -1,17 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.Alliance;
public class CreateAllianceDto
{
[Required]
public int Server { get; set; }
[Required]
[MaxLength(200)]
public required string Name { get; set; }
[Required]
[MaxLength(5)]
public required string Abbreviation { get; set; }
}

View File

@ -13,4 +13,7 @@ public class UpdateAllianceDto
[Required]
[MaxLength(5)]
public required string Abbreviation { get; set; }
[Required]
public int Server { get; set; }
}

View File

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.Authentication;
public class ConfirmEmailRequestDto
{
[Required]
[EmailAddress]
public required string Email { get; set; }
[Required]
public required string Token { get; set; }
}

View File

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.Authentication;
public class EmailConfirmationRequestDto
{
[Required]
[EmailAddress]
public required string Email { get; set; }
[Required]
public required string ClientUri { get; set; }
}

View File

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.Authentication;
public class ForgotPasswordDto
{
[Required]
[EmailAddress]
public required string Email { get; set; }
[Required]
public required string ResetPasswordUri { get; set; }
}

View File

@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.Authentication;
public class InviteUserDto
{
[Required]
[EmailAddress]
public required string Email { get; set; }
[Required]
public Guid InvitingUserId { get; set; }
[Required]
public Guid AllianceId { get; set; }
[Required]
public required string Role { get; set; }
[Required]
public required string RegisterUserUri { get; set; }
}

View File

@ -0,0 +1,26 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.Authentication;
public class RegisterUserDto
{
[Required]
[EmailAddress]
public required string Email { get; set; }
[Required]
[MaxLength(200)]
public required string PlayerName { get; set; }
[Required]
public required string Password { get; set; }
[Required]
public Guid AllianceId { get; set; }
[Required]
public Guid RoleId { get; set; }
[Required]
public required string EmailConfirmUri { get; set; }
}

View File

@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.Authentication;
public class ResetPasswordDto
{
[Required]
public required string Password { get; set; }
[Compare("Password")]
public required string ConfirmPassword { get; set; }
[Required]
[EmailAddress]
public required string Email { get; set; }
[Required]
public required string Token { get; set; }
}

View File

@ -2,7 +2,7 @@
namespace Application.DataTransferObjects.Authentication;
public class RegisterRequestDto
public class SignUpRequestDto
{
[Required]
[EmailAddress]
@ -25,4 +25,7 @@ public class RegisterRequestDto
[Required]
[MaxLength(5)]
public required string AllianceAbbreviation { get; set; }
[Required]
public required string EmailConfirmUri { get; set; }
}

View File

@ -0,0 +1,26 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.CustomEvent;
public class CreateCustomEventDto
{
[Required]
[MaxLength(150)]
public required string Name { get; set; }
[Required]
public bool IsPointsEvent { get; set; }
[Required]
public bool IsParticipationEvent { get; set; }
[Required]
[MaxLength(500)]
public required string Description { get; set; }
[Required]
public Guid AllianceId { get; set; }
[Required]
public required string EventDateString { get; set; }
}

View File

@ -0,0 +1,8 @@
using Application.DataTransferObjects.CustomEventParticipant;
namespace Application.DataTransferObjects.CustomEvent;
public class CustomEventDetailDto : CustomEventDto
{
public ICollection<CustomEventParticipantDto> CustomEventParticipants { get; set; } = [];
}

View File

@ -0,0 +1,25 @@
namespace Application.DataTransferObjects.CustomEvent;
public class CustomEventDto
{
public Guid Id { get; set; }
public Guid AllianceId { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public bool IsPointsEvent { get; set; }
public bool IsParticipationEvent { get; set; }
public DateTime EventDate { get; set; }
public required string CreatedBy { get; set; }
public DateTime? ModifiedOn { get; set; }
public string? ModifiedBy { get; set; }
}

View File

@ -0,0 +1,27 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.CustomEvent;
public class UpdateCustomEventDto
{
[Required]
public Guid Id { get; set; }
[Required]
[MaxLength(150)]
public required string Name { get; set; }
[Required]
public bool IsPointsEvent { get; set; }
[Required]
public bool IsParticipationEvent { get; set; }
[Required]
[MaxLength(500)]
public required string Description { get; set; }
[Required]
public required string EventDateString { get; set; }
}

View File

@ -0,0 +1,16 @@
namespace Application.DataTransferObjects.CustomEventParticipant;
public class CustomEventParticipantDto
{
public Guid Id { get; set; }
public Guid PlayerId { get; set; }
public Guid CustomEventId { get; set; }
public bool? Participated { get; set; }
public long? AchievedPoints { get; set; }
public required string PlayerName { get; set; }
}

View File

@ -1,10 +1,25 @@
namespace Application.DataTransferObjects.DesertStorm;
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.DesertStorm;
public class CreateDesertStormDto
{
public Guid PlayerId { get; set; }
[Required]
public Guid AllianceId { get; set; }
public bool Registered { get; set; }
[Required]
public bool Won { get; set; }
public bool Participated { get; set; }
[Required]
public int OpposingParticipants { get; set; }
[Required]
public int OpponentServer { get; set; }
[Required]
public required string EventDate { get; set; }
[Required]
[MaxLength(150)]
public required string OpponentName { get; set; }
}

View File

@ -0,0 +1,8 @@
using Application.DataTransferObjects.DesertStormParticipants;
namespace Application.DataTransferObjects.DesertStorm;
public class DesertStormDetailDto : DesertStormDto
{
public ICollection<DesertStormParticipantDto> DesertStormParticipants { get; set; } = [];
}

View File

@ -4,11 +4,23 @@ public class DesertStormDto
{
public Guid Id { get; set; }
public bool Registered { get; set; }
public bool Won { get; set; }
public bool Participated { get; set; }
public int OpposingParticipants { get; set; }
public int Year { get; set; }
public int OpponentServer { get; set; }
public int CalendarWeek { get; set; }
public DateTime EventDate { get; set; }
public required string OpponentName { get; set; }
public Guid AllianceId { get; set; }
public string? ModifiedBy { get; set; }
public DateTime? ModifiedOn { get; set; }
public required string CreatedBy { get; set; }
public int Participants { get; set; }
}

View File

@ -1,16 +1,23 @@
namespace Application.DataTransferObjects.DesertStorm;
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.DesertStorm;
public class UpdateDesertStormDto
{
public Guid Id { get; set; }
public Guid PlayerId { get; set; }
[Required]
public bool Won { get; set; }
public bool Registered { get; set; }
[Required]
public int OpposingParticipants { get; set; }
public bool Participated { get; set; }
[Required]
public int OpponentServer { get; set; }
public int Year { get; set; }
public DateTime EventDate { get; set; } = DateTime.Now;
public int CalendarWeek { get; set; }
[Required]
[MaxLength(150)]
public required string OpponentName { get; set; }
}

View File

@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.DesertStormParticipants;
public class CreateDesertStormParticipantDto
{
[Required]
public Guid DesertStormId { get; set; }
[Required]
public Guid PlayerId { get; set; }
[Required]
public bool Registered { get; set; }
[Required]
public bool Participated { get; set; }
[Required]
public bool StartPlayer { get; set; }
}

View File

@ -0,0 +1,18 @@
namespace Application.DataTransferObjects.DesertStormParticipants;
public class DesertStormParticipantDto
{
public Guid Id { get; set; }
public Guid DesertStormId { get; set; }
public Guid PlayerId { get; set; }
public required string PlayerName { get; set; }
public bool Registered { get; set; }
public bool Participated { get; set; }
public bool StartPlayer { get; set; }
}

View File

@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.DesertStormParticipants;
public class UpdateDesertStormParticipantDto
{
[Required]
public Guid Id { get; set; }
[Required]
public Guid DesertStormId { get; set; }
[Required]
public Guid PlayerId { get; set; }
[Required]
public bool Registered { get; set; }
[Required]
public bool Participated { get; set; }
[Required]
public bool StartPlayer { get; set; }
}

View File

@ -5,9 +5,18 @@ namespace Application.DataTransferObjects.MarshalGuard;
public class CreateMarshalGuardDto
{
[Required]
public Guid PlayerId { get; set; }
public Guid AllianceId { get; set; }
[Required]
public bool Participated { get; set; }
public int RewardPhase { get; set; }
[Required]
public int Level { get; set; }
[Required]
public int AllianceSize { get; set; }
[Required]
public required string EventDate { get; set; }
}

View File

@ -0,0 +1,8 @@
using Application.DataTransferObjects.MarshalGuardParticipant;
namespace Application.DataTransferObjects.MarshalGuard;
public class MarshalGuardDetailDto : MarshalGuardDto
{
public ICollection<MarshalGuardParticipantDto> MarshalGuardParticipants { get; set; } = [];
}

View File

@ -4,11 +4,21 @@ public class MarshalGuardDto
{
public Guid Id { get; set; }
public bool Participated { get; set; }
public Guid AllianceId { get; set; }
public int Year { get; set; }
public int Participants { get; set; }
public int Month { get; set; }
public int RewardPhase { get; set; }
public int Day { get; set; }
public int Level { get; set; }
public int AllianceSize { get; set; }
public DateTime EventDate { get; set; }
public required string CreatedBy { get; set; }
public DateTime? ModifiedOn { get; set; }
public string? ModifiedBy { get; set; }
}

View File

@ -8,17 +8,17 @@ public class UpdateMarshalGuardDto
public Guid Id { get; set; }
[Required]
public Guid PlayerId { get; set; }
public Guid AllianceId { get; set; }
[Required]
public bool Participated { get; set; }
public int Participants { get; set; }
[Required]
public int Year { get; set; }
public int Level { get; set; }
[Required]
public int Month { get; set; }
public int RewardPhase { get; set; }
[Required]
public int Day { get; set; }
public required string EventDate { get; set; }
}

View File

@ -0,0 +1,10 @@
namespace Application.DataTransferObjects.MarshalGuardParticipant;
public class CreateMarshalGuardParticipantDto
{
public Guid PlayerId { get; set; }
public Guid MarshalGuardId { get; set; }
public bool Participated { get; set; }
}

View File

@ -0,0 +1,14 @@
namespace Application.DataTransferObjects.MarshalGuardParticipant;
public class MarshalGuardParticipantDto
{
public Guid Id { get; set; }
public Guid PlayerId { get; set; }
public Guid MarshalGuardId { get; set; }
public bool Participated { get; set; }
public required string PlayerName { get; set; }
}

View File

@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.MarshalGuardParticipant;
public class UpdateMarshalGuardParticipantDto
{
[Required]
public Guid Id { get; set; }
[Required]
public Guid PlayerId { get; set; }
[Required]
public Guid MarshalGuardId { get; set; }
[Required]
public bool Participated { get; set; }
}

View File

@ -7,6 +7,8 @@ public class CreateNoteDto
[Required]
public Guid PlayerId { get; set; }
public DateTime CreatedOn { get; set; } = DateTime.Now;
[Required]
[MaxLength(500)]
public required string PlayerNote { get; set; }

View File

@ -4,5 +4,15 @@ public class NoteDto
{
public Guid Id { get; set; }
public Guid PlayerId { get; set; }
public DateTime CreatedOn { get; set; }
public required string CreatedBy { get; set; }
public required string PlayerNote { get; set; }
public DateTime? ModifiedOn { get; set; }
public string? ModifiedBy { get; set; }
}

View File

@ -15,6 +15,5 @@ public class CreatePlayerDto
public Guid AllianceId { get; set; }
[Required]
[MaxLength(3)]
public required string Level { get; set; }
public int Level { get; set; }
}

View File

@ -1,12 +1,30 @@
namespace Application.DataTransferObjects.Player;
using System.Runtime.InteropServices.JavaScript;
namespace Application.DataTransferObjects.Player;
public class PlayerDto
{
public Guid Id { get; set; }
public Guid RankId { get; set; }
public Guid AllianceId { get; set; }
public required string PlayerName { get; set; }
public required string Level { get; set; }
public int Level { get; set; }
public required string RankName { get; set; }
public int NotesCount { get; set; }
public int AdmonitionsCount { get; set; }
public DateTime CreatedOn { get; set; }
public required string CreatedBy { get; set; }
public DateTime? ModifiedOn { get; set; }
public string? ModifiedBy { get; set; }
}

View File

@ -13,6 +13,5 @@ public class UpdatePlayerDto
public Guid RankId { get; set; }
[Required]
[MaxLength(3)]
public required string Level { get; set; }
public int Level { get; set; }
}

View File

@ -0,0 +1,8 @@
namespace Application.DataTransferObjects.Rank;
public class RankDto
{
public Guid Id { get; set; }
public required string Name { get; set; }
}

View File

@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.User;
public class ChangePasswordDto
{
[Required]
public Guid UserId { get; set; }
[Required]
public required string CurrentPassword { get; set; }
[Required]
public required string NewPassword { get; set; }
[Required]
public required string ConfirmPassword { get; set; }
}

View File

@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
namespace Application.DataTransferObjects.User;
public class UpdateUserDto
{
[Required]
public Guid Id { get; set; }
[Required]
[MaxLength(200)]
public required string PlayerName { get; set; }
[Required]
public required string Role { get; set; }
}

View File

@ -0,0 +1,14 @@
namespace Application.DataTransferObjects.User;
public class UserDto
{
public Guid Id { get; set; }
public Guid AllianceId { get; set; }
public required string PlayerName { get; set; }
public required string Email { get; set; }
public required string Role { get; set; }
}

View File

@ -5,9 +5,25 @@ namespace Application.DataTransferObjects.VsDuel;
public class CreateVsDuelDto
{
[Required]
public Guid PlayerId { get; set; }
public Guid AllianceId { get; set; }
[Required]
public int WeeklyPoints { get; set; }
public required string EventDate { get; set; }
[Required]
public bool Won { get; set; }
[Required]
[MaxLength(150)]
public required string OpponentName { get; set; }
[Required]
public int OpponentServer { get; set; }
[Required]
public long OpponentPower { get; set; }
[Required]
public int OpponentSize { get; set; }
}

View File

@ -8,14 +8,24 @@ public class UpdateVsDuelDto
public Guid Id { get; set; }
[Required]
public Guid PlayerId { get; set; }
public Guid AllianceId { get; set; }
[Required]
public int WeeklyPoints { get; set; }
public required string EventDate { get; set; }
[Required]
public int Year { get; set; }
public bool Won { get; set; }
[Required]
public int CalendarWeek { get; set; }
[MaxLength(150)]
public required string OpponentName { get; set; }
[Required]
public int OpponentServer { get; set; }
[Required]
public long OpponentPower { get; set; }
[Required]
public int OpponentSize { get; set; }
}

View File

@ -0,0 +1,8 @@
using Application.DataTransferObjects.VsDuelParticipant;
namespace Application.DataTransferObjects.VsDuel;
public class VsDuelDetailDto : VsDuelDto
{
public ICollection<VsDuelParticipantDto> VsDuelParticipants { get; set; } = [];
}

View File

@ -1,13 +1,29 @@
namespace Application.DataTransferObjects.VsDuel;
using Database.Entities;
namespace Application.DataTransferObjects.VsDuel;
public class VsDuelDto
{
public Guid Id { get; set; }
public int WeeklyPoints { get; set; }
public Guid AllianceId { get; set; }
public int Year { get; set; }
public DateTime EventDate { get; set; }
public int CalendarWeek { get; set; }
public required string CreatedBy { get; set; }
public bool Won { get; set; }
public required string OpponentName { get; set; }
public int OpponentServer { get; set; }
public long OpponentPower { get; set; }
public int OpponentSize { get; set; }
public DateTime? ModifiedOn { get; set; }
public string? ModifiedBy { get; set; }
}

View File

@ -0,0 +1,14 @@
namespace Application.DataTransferObjects.VsDuelParticipant;
public class VsDuelParticipantDto
{
public Guid Id { get; set; }
public Guid PlayerId { get; set; }
public Guid VsDuelId { get; set; }
public long WeeklyPoints { get; set; }
public required string PlayerName { get; set; }
}

View File

@ -4,9 +4,18 @@ public static class AuthenticationErrors
{
public static readonly Error LoginFailed = new("Error.Authentication.LoginFailed", "Email or password incorrect");
public static readonly Error EmailNotConfirmed =
new("Error.Authentication.EmailNotConfirmed", "Email is not confirmed");
public static readonly Error RegisterFailed =
new("Error.Authentication.RegisterFailed", "Could not create an account");
public static readonly Error AllianceAlreadyExists =
new("Error.Authentication.AllianceAlreadyExists", "Alliance already exists");
public static readonly Error ResendConfirmationEmailFailed = new("Error.Authentication.ResendConfirmEmailFailed",
"Error while resend the email confirmation email");
public static readonly Error InviteUserFailed = new("Error.Authentication.InviteUser",
"Error while send email for inviting");
}

View File

@ -0,0 +1,9 @@
namespace Application.Errors;
public static class CustomEventErrors
{
public static readonly Error NotFound = new("Error.CustomEvent.NotFound",
"The custom event with the specified identifier was not found");
public static readonly Error IdConflict = new("Error.CustomEvent.IdConflict", "There is a conflict with the id's");
}

View File

@ -0,0 +1,7 @@
namespace Application.Errors;
public static class RoleErrors
{
public static readonly Error NotFound = new("Error.Role.NotFound",
"The role with the specified identifier was not found");
}

View File

@ -0,0 +1,15 @@
namespace Application.Errors;
public class UserErrors
{
public static readonly Error NotFound = new("Error.User.NotFound",
"The user with the specified identifier was not found");
public static readonly Error IdConflict = new("Error.User.IdConflict", "There is a conflict with the id's");
public static readonly Error CurrentPasswordNotMatch = new("Error.User.CurrentPassword", "The current password is invalid");
public static readonly Error ChangePasswordFailed = new("Error.User.ChangePasswordFailed", "Password change failed");
public static readonly Error ConfirmPasswordNotMatch = new("Error.User.ConfirmPasswordNotMatch", "The confirm password not match");
}

View File

@ -0,0 +1,9 @@
namespace Application.Errors;
public class VsDuelParticipantErrors
{
public static readonly Error NotFound = new("Error.VsDuelParticipant.NotFound",
"The VsDuelParticipant with the specified identifier was not found");
public static readonly Error IdConflict = new("Error.VsDuelParticipant.IdConflict", "There is a conflict with the id's");
}

View File

@ -0,0 +1,18 @@
using Application.Interfaces;
namespace Application.Helpers.Email;
public static class EmailTemplateFactory
{
public static IEmailTemplate GetEmailTemplate(string languageCode)
{
return languageCode switch
{
"en" => new EnglishEmailTemplate(),
"de" => new GermanEmailTemplate(),
"fr" => new FrenchEmailTemplate(),
"it" => new ItalianEmailTemplate(),
_ => new EnglishEmailTemplate()
};
}
}

View File

@ -0,0 +1,301 @@
using Application.Classes;
using Application.Interfaces;
namespace Application.Helpers.Email;
public class EnglishEmailTemplate : IEmailTemplate
{
public EmailContent ConfirmEmail(string userName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Please Confirm Your Email Address",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #4CAF50;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #4CAF50;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Welcome, {userName}!</h1>
</div>
<div class='content'>
<p>Thank you for registering with <strong>Last War Playermanager</strong>.</p>
<p>Please confirm your email address by clicking the button below. This confirmation is only valid for 2 hours:</p>
<a href='{callBack}' class='button'>Confirm Email</a>
</div>
<div class='footer'>
<p>This email was automatically generated. Please do not reply to this email.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
public EmailContent ResendConfirmationEmail(string userName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Resend Confirmation of Your Email Address",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Hello, {userName}!</h1>
</div>
<div class='content'>
<p>You have requested to resend the confirmation of your email address.</p>
<p>Please confirm your email address by clicking the button below. This confirmation is valid for 2 hours only:</p>
<a href='{callBack}' class='button'>Confirm Email</a>
</div>
<div class='footer'>
<p>This email was automatically generated. Please do not reply to this email.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
public EmailContent InviteUserEmail(string invitingUserName, string allianceName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Invitation to Last War Playermanager",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Invitation to Last War Playermanager</h1>
</div>
<div class='content'>
<p>{invitingUserName} is inviting you to join the Last War Playermanager.</p>
<p>Your alliance, <strong>{allianceName}</strong>, is looking forward to your participation! Click the button below to accept the invitation:</p>
<a href='{callBack}' class='button'>Join Now</a>
</div>
<div class='footer'>
<p>This email was generated automatically. Please do not reply to this email.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
public EmailContent ResetPasswordEmail(string userName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Password Reset - Last War Playermanager",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Password Reset Request</h1>
</div>
<div class='content'>
<p>Hello {userName},</p>
<p>We received a request to reset the password for your Last War Playermanager account. If you did not make this request, you can simply ignore this email.</p>
<p>To reset your password, please click the button below. The link is valid for the next 2 hours:</p>
<a href='{callBack}' class='button'>Reset Password</a>
</div>
<div class='footer'>
<p>This email was automatically generated. Please do not reply to this email.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
}

View File

@ -0,0 +1,165 @@
using Application.Classes;
using Application.Interfaces;
namespace Application.Helpers.Email;
public class FrenchEmailTemplate : IEmailTemplate
{
public EmailContent ConfirmEmail(string userName, string callBack)
{
throw new NotImplementedException();
}
public EmailContent ResendConfirmationEmail(string userName, string callBack)
{
throw new NotImplementedException();
}
public EmailContent InviteUserEmail(string invitingUserName, string allianceName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Invitation au Last War Playermanager",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Invitation au Last War Playermanager</h1>
</div>
<div class='content'>
<p>{invitingUserName} vous invite à rejoindre le Last War Playermanager.</p>
<p>Votre alliance, <strong>{allianceName}</strong>, attend avec impatience votre participation ! Cliquez sur le bouton ci-dessous pour accepter l'invitation :</p>
<a href='{callBack}' class='button'>Rejoindre maintenant</a>
</div>
<div class='footer'>
<p>Ce courriel a é généré automatiquement. Veuillez ne pas répondre à ce courriel.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
public EmailContent ResetPasswordEmail(string userName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Réinitialisation du mot de passe - Last War Playermanager",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Demande de réinitialisation du mot de passe</h1>
</div>
<div class='content'>
<p>Bonjour {userName},</p>
<p>Nous avons reçu une demande de réinitialisation du mot de passe pour votre compte Last War Playermanager. Si vous n'avez pas fait cette demande, vous pouvez ignorer cet e-mail.</p>
<p>Pour réinitialiser votre mot de passe, veuillez cliquer sur le bouton ci-dessous. Le lien est valable pour les 2 prochaines heures :</p>
<a href='{callBack}' class='button'>Réinitialiser le mot de passe</a>
</div>
<div class='footer'>
<p>Cet e-mail a é généré automatiquement. Veuillez ne pas répondre à cet e-mail.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
}

View File

@ -0,0 +1,300 @@
using Application.Classes;
using Application.Interfaces;
namespace Application.Helpers.Email;
public class GermanEmailTemplate : IEmailTemplate
{
public EmailContent ConfirmEmail(string userName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Bitte bestätigen Sie Ihre E-Mail-Adresse",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #4CAF50;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #4CAF50;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Willkommen, {userName}!</h1>
</div>
<div class='content'>
<p>Vielen Dank, dass Sie sich für <strong>Last War Playermanager</strong> registriert haben.</p>
<p>Bitte bestätigen Sie Ihre E-Mail-Adresse, indem Sie auf den folgenden Button klicken. Diese Bestätigung ist nur 2 Stunden gültig:</p>
<a href='{callBack}' class='button'>E-Mail bestätigen</a>
</div>
<div class='footer'>
<p>Diese E-Mail wurde automatisch generiert. Bitte antworten Sie nicht auf diese E-Mail.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
public EmailContent ResendConfirmationEmail(string userName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Erneute Bestätigung Ihrer E-Mail-Adresse",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Hallo, {userName}!</h1>
</div>
<div class='content'>
<p>Sie haben eine erneute Bestätigung Ihrer E-Mail-Adresse angefordert.</p>
<p>Bitte bestätigen Sie Ihre E-Mail-Adresse, indem Sie auf den folgenden Button klicken. Diese Bestätigung ist nur 2 Stunden gültig:</p>
<a href='{callBack}' class='button'>E-Mail bestätigen</a>
</div>
<div class='footer'>
<p>Diese E-Mail wurde automatisch generiert. Bitte antworten Sie nicht auf diese E-Mail.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
public EmailContent InviteUserEmail(string invitingUserName, string allianceName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Einladung zum Last War Playermanager",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Einladung zum Last War Playermanager</h1>
</div>
<div class='content'>
<p>{invitingUserName} lädt Sie ein, dem Last War Playermanager beizutreten.</p>
<p>Ihre Allianz, <strong>{allianceName}</strong>, freut sich auf Ihre Teilnahme! Klicken Sie auf den folgenden Button, um der Einladung zu folgen:</p>
<a href='{callBack}' class='button'>Jetzt beitreten</a>
</div>
<div class='footer'>
<p>Diese E-Mail wurde automatisch generiert. Bitte antworten Sie nicht auf diese E-Mail.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
public EmailContent ResetPasswordEmail(string userName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Passwort-Zurücksetzung - Last War Playermanager",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Anfrage zur Passwort-Zurücksetzung</h1>
</div>
<div class='content'>
<p>Hallo {userName},</p>
<p>Wir haben eine Anfrage erhalten, das Passwort für dein Last War Playermanager-Konto zurückzusetzen. Wenn du diese Anfrage nicht gestellt hast, kannst du diese E-Mail einfach ignorieren.</p>
<p>Um dein Passwort zurückzusetzen, klicke bitte auf den untenstehenden Button. Der Link ist für die nächsten 2 Stunden gültig:</p>
<a href='{callBack}' class='button'>Passwort zurücksetzen</a>
</div>
<div class='footer'>
<p>Diese E-Mail wurde automatisch generiert. Bitte antworte nicht auf diese E-Mail.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
}

View File

@ -0,0 +1,165 @@
using Application.Classes;
using Application.Interfaces;
namespace Application.Helpers.Email;
public class ItalianEmailTemplate : IEmailTemplate
{
public EmailContent ConfirmEmail(string userName, string callBack)
{
throw new NotImplementedException();
}
public EmailContent ResendConfirmationEmail(string userName, string callBack)
{
throw new NotImplementedException();
}
public EmailContent InviteUserEmail(string invitingUserName, string allianceName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Invito al Last War Playermanager",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Invito al Last War Playermanager</h1>
</div>
<div class='content'>
<p>{invitingUserName} ti invita a unirti al Last War Playermanager.</p>
<p>La tua alleanza, <strong>{allianceName}</strong>, è in attesa della tua partecipazione! Clicca sul pulsante qui sotto per accettare l'invito:</p>
<a href='{callBack}' class='button'>Unisciti ora</a>
</div>
<div class='footer'>
<p>Questa email è stata generata automaticamente. Si prega di non rispondere a questa email.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
public EmailContent ResetPasswordEmail(string userName, string callBack)
{
var emailContent = new EmailContent()
{
Subject = "Reimpostazione della password - Last War Playermanager",
Content = $@"
<html>
<head>
<style>
body {{
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333333;
margin: 0;
padding: 0;
}}
.container {{
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #dddddd;
}}
.header {{
text-align: center;
padding: 10px 0;
background-color: #FFA500;
color: #ffffff;
}}
.content {{
padding: 20px;
}}
.button {{
display: inline-block;
padding: 15px 25px;
background-color: #FFA500;
color: white;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 5px;
margin: 20px 0;
}}
.footer {{
text-align: center;
padding: 10px;
font-size: 12px;
color: #999999;
}}
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Richiesta di reimpostazione della password</h1>
</div>
<div class='content'>
<p>Ciao {userName},</p>
<p>Abbiamo ricevuto una richiesta di reimpostazione della password per il tuo account Last War Playermanager. Se non hai fatto questa richiesta, puoi ignorare questa email.</p>
<p>Per reimpostare la tua password, fai clic sul pulsante qui sotto. Il link è valido per le prossime 2 ore:</p>
<a href='{callBack}' class='button'>Reimposta la password</a>
</div>
<div class='footer'>
<p>Questa email è stata generata automaticamente. Per favore, non rispondere a questa email.</p>
</div>
</div>
</body>
</html>"
};
return emailContent;
}
}

View File

@ -0,0 +1,22 @@
using System.Web;
namespace Application.Helpers;
public static class HttpExtensions
{
public static Uri AddQueryParam(this Uri uri, string name, string value)
{
var httpValueCollection = HttpUtility.ParseQueryString(uri.Query);
httpValueCollection.Remove(name);
httpValueCollection.Add(name, value);
var uriBuilder = new UriBuilder(uri)
{
Query = httpValueCollection.ToString() ?? string.Empty,
};
return uriBuilder.Uri;
}
}

View File

@ -11,9 +11,9 @@ public interface IAdmonitionRepository
Task<Result<AdmonitionDto>> GetAdmonitionAsync(Guid admonitionId, CancellationToken cancellationToken);
Task<Result<AdmonitionDto>> CreateAdmonitionAsync(CreateAdmonitionDto createAdmonitionDto, CancellationToken cancellationToken);
Task<Result<AdmonitionDto>> CreateAdmonitionAsync(CreateAdmonitionDto createAdmonitionDto, string createdBy, CancellationToken cancellationToken);
Task<Result<AdmonitionDto>> UpdateAdmonitionAsync(UpdateAdmonitionDto updateAdmonitionDto, CancellationToken cancellationToken);
Task<Result<AdmonitionDto>> UpdateAdmonitionAsync(UpdateAdmonitionDto updateAdmonitionDto, string modifiedBy, CancellationToken cancellationToken);
Task<Result<bool>> DeleteAdmonitionAsync(Guid admonitionId, CancellationToken cancellationToken);
}

View File

@ -9,9 +9,7 @@ public interface IAllianceRepository
Task<Result<AllianceDto>> GetAllianceAsync(Guid allianceId, CancellationToken cancellationToken);
Task<Result<AllianceDto>> CreateAllianceAsync(CreateAllianceDto createAllianceDto, CancellationToken cancellationToken);
Task<Result<AllianceDto>> UpdateAllianceAsync(UpdateAllianceDto updateAllianceDto, CancellationToken cancellationToken);
Task<Result<AllianceDto>> UpdateAllianceAsync(UpdateAllianceDto updateAllianceDto, string modifiedBy, CancellationToken cancellationToken);
Task<Result<bool>> DeleteAllianceAsync(Guid allianceId, CancellationToken cancellationToken);
}

View File

@ -7,5 +7,18 @@ public interface IAuthenticationRepository
{
Task<Result<LoginResponseDto>> LoginAsync(LoginRequestDto loginRequestDto, CancellationToken cancellationToken);
Task<Result<LoginResponseDto>> RegisterToApplicationAsync(RegisterRequestDto registerRequestDto, CancellationToken cancellationToken);
Task<Result> RegisterToApplicationAsync(SignUpRequestDto signUpRequestDto, CancellationToken cancellationToken);
Task<Result> RegisterUserAsync(RegisterUserDto registerUserDto, CancellationToken cancellationToken);
Task<Result> EmailConfirmationAsync(ConfirmEmailRequestDto confirmEmailRequestDto);
Task<Result> ResendConfirmationEmailAsync(EmailConfirmationRequestDto emailConfirmationRequestDto);
Task<Result> InviteUserAsync(InviteUserDto inviteUserDto, CancellationToken cancellationToken);
Task<Result> ResetPasswordAsync(ResetPasswordDto resetPasswordDto);
Task<Result> ForgotPasswordAsync(ForgotPasswordDto forgotPasswordDto);
}

View File

@ -0,0 +1,8 @@
using System.Security.Claims;
namespace Application.Interfaces;
public interface IClaimTypeService
{
string GetFullName(ClaimsPrincipal claimsPrincipal);
}

View File

@ -0,0 +1,21 @@
using Application.Classes;
using Application.DataTransferObjects.CustomEvent;
namespace Application.Interfaces;
public interface ICustomEventRepository
{
Task<Result<CustomEventDto>> GetCustomEventAsync(Guid customEventId, CancellationToken cancellationToken);
Task<Result<CustomEventDetailDto>> GetCustomEventDetailAsync(Guid customEventId, CancellationToken cancellationToken);
Task<Result<List<CustomEventDto>>> GetAllianceCustomEventsAsync(Guid allianceId, int take, CancellationToken cancellationToken);
Task<Result<CustomEventDto>> CreateCustomEventAsync(CreateCustomEventDto createCustomEventDto, string createdBy,
CancellationToken cancellationToken);
Task<Result<CustomEventDto>> UpdateCustomEventAsync(UpdateCustomEventDto updateCustomEventDto, string modifiedBy,
CancellationToken cancellationToken);
Task<Result<bool>> DeleteCustomEventAsync(Guid customEventId, CancellationToken cancellationToken);
}

View File

@ -0,0 +1,17 @@
using Application.Classes;
using Application.DataTransferObjects.DesertStormParticipants;
namespace Application.Interfaces;
public interface IDesertStormParticipantRepository
{
Task<Result<DesertStormParticipantDto>> GetDesertStormParticipantAsync(Guid desertStormParticipantId,
CancellationToken cancellationToken);
Task<Result<bool>> InsertDesertStormParticipantAsync(
List<CreateDesertStormParticipantDto> createDesertStormParticipants, CancellationToken cancellationToken);
Task<Result<List<DesertStormParticipantDto>>> GetPlayerDesertStormParticipantsAsync(Guid playerId, int last, CancellationToken cancellationToken);
Task<Result<DesertStormParticipantDto>> UpdateDesertStormParticipantAsync(
UpdateDesertStormParticipantDto updateDesertStormParticipantDto, CancellationToken cancellationToken);
}

View File

@ -7,11 +7,13 @@ public interface IDesertStormRepository
{
Task<Result<DesertStormDto>> GetDesertStormAsync(Guid desertStormId, CancellationToken cancellationToken);
Task<Result<List<DesertStormDto>>> GetPlayerDesertStormsAsync(Guid playerId, CancellationToken cancellationToken);
Task<Result<List<DesertStormDto>>> GetAllianceDesertStormsAsync(Guid allianceId, int take, CancellationToken cancellationToken);
Task<Result<DesertStormDto>> CreateDesertStormAsync(CreateDesertStormDto createDesertStormDto, CancellationToken cancellationToken);
Task<Result<DesertStormDetailDto>> GetDesertStormDetailAsync(Guid desertStormId, CancellationToken cancellationToken);
Task<Result<DesertStormDto>> UpdateDesertStormAsync(UpdateDesertStormDto updateDesertStormDto, CancellationToken cancellationToken);
Task<Result<DesertStormDto>> CreateDesertStormAsync(CreateDesertStormDto createDesertStormDto, string createdBy, CancellationToken cancellationToken);
Task<Result<DesertStormDto>> UpdateDesertStormAsync(UpdateDesertStormDto updateDesertStormDto, string modifiedBy, CancellationToken cancellationToken);
Task<Result<bool>> DeleteDesertStormAsync(Guid desertStormId, CancellationToken cancellationToken);
}

View File

@ -0,0 +1,14 @@
using Application.Classes;
namespace Application.Interfaces;
public interface IEmailTemplate
{
public EmailContent ConfirmEmail(string userName, string callBack);
public EmailContent ResendConfirmationEmail (string userName, string callBack);
public EmailContent InviteUserEmail(string invitingUserName, string allianceName, string callBack);
public EmailContent ResetPasswordEmail(string userName, string callBack);
}

View File

@ -0,0 +1,17 @@
using Application.Classes;
using Application.DataTransferObjects.MarshalGuardParticipant;
namespace Application.Interfaces;
public interface IMarshalGuardParticipantRepository
{
Task<Result<MarshalGuardParticipantDto>> GetMarshalGuardParticipantAsync(Guid marshalGuardParticipantId,
CancellationToken cancellationToken);
Task<Result<bool>> InsertMarshalGuardParticipantAsync(
List<CreateMarshalGuardParticipantDto> createMarshalGuardParticipantsDto, CancellationToken cancellationToken);
Task<Result<List<MarshalGuardParticipantDto>>> GetPlayerMarshalParticipantsAsync(Guid playerId, int last, CancellationToken cancellationToken);
Task<Result<MarshalGuardParticipantDto>> UpdateMarshalGuardParticipantAsync(
UpdateMarshalGuardParticipantDto updateMarshalGuardParticipantDto, CancellationToken cancellationToken);
}

View File

@ -7,11 +7,13 @@ public interface IMarshalGuardRepository
{
Task<Result<MarshalGuardDto>> GetMarshalGuardAsync(Guid marshalGuardId, CancellationToken cancellationToken);
Task<Result<List<MarshalGuardDto>>> GetPlayerMarshalGuardsAsync(Guid playerId, CancellationToken cancellationToken);
Task<Result<MarshalGuardDetailDto>> GetMarshalGuardDetailAsync(Guid marshalGuardId, CancellationToken cancellationToken);
Task<Result<MarshalGuardDto>> CreateMarshalGuardAsync(CreateMarshalGuardDto createMarshalGuardDto, CancellationToken cancellationToken);
Task<Result<List<MarshalGuardDto>>> GetAllianceMarshalGuardsAsync(Guid allianceId, int take, CancellationToken cancellationToken);
Task<Result<MarshalGuardDto>> UpdateMarshalGuardAsync(UpdateMarshalGuardDto updateMarshalGuardDto, CancellationToken cancellationToken);
Task<Result<MarshalGuardDto>> CreateMarshalGuardsAsync(CreateMarshalGuardDto createMarshalGuardDto, string createdBy, CancellationToken cancellationToken);
Task<Result<MarshalGuardDto>> UpdateMarshalGuardAsync(UpdateMarshalGuardDto updateMarshalGuardDto, string modifiedBy, CancellationToken cancellationToken);
Task<Result<bool>> DeleteMarshalGuardAsync(Guid marshalGuardId, CancellationToken cancellationToken);
}

View File

@ -9,9 +9,9 @@ public interface INoteRepository
Task<Result<List<NoteDto>>> GetPlayerNotesAsync(Guid playerId, CancellationToken cancellationToken);
Task<Result<NoteDto>> CreateNoteAsync(CreateNoteDto createNoteDto, CancellationToken cancellationToken);
Task<Result<NoteDto>> CreateNoteAsync(CreateNoteDto createNoteDto, string createdBy, CancellationToken cancellationToken);
Task<Result<NoteDto>> UpdateNoteAsync(UpdateNoteDto updateNoteDto, CancellationToken cancellationToken);
Task<Result<NoteDto>> UpdateNoteAsync(UpdateNoteDto updateNoteDto, string modifiedBy, CancellationToken cancellationToken);
Task<Result<bool>> DeleteNoteAsync(Guid noteId, CancellationToken cancellationToken);
}

View File

@ -9,9 +9,9 @@ public interface IPlayerRepository
Task<Result<List<PlayerDto>>> GetAlliancePlayersAsync(Guid allianceId, CancellationToken cancellationToken);
Task<Result<PlayerDto>> CreatePlayerAsync(CreatePlayerDto createPlayerDto, CancellationToken cancellationToken);
Task<Result<PlayerDto>> CreatePlayerAsync(CreatePlayerDto createPlayerDto, string createdBy, CancellationToken cancellationToken);
Task<Result<PlayerDto>> UpdatePlayerAsync(UpdatePlayerDto updatePlayerDto, CancellationToken cancellationToken);
Task<Result<PlayerDto>> UpdatePlayerAsync(UpdatePlayerDto updatePlayerDto, string modifiedBy, CancellationToken cancellationToken);
Task<Result<bool>> DeletePlayerAsync(Guid playerIId, CancellationToken cancellationToken);
}

View File

@ -0,0 +1,9 @@
using Application.Classes;
using Application.DataTransferObjects.Rank;
namespace Application.Interfaces;
public interface IRankRepository
{
Task<Result<List<RankDto>>> GetRanksAsync(CancellationToken cancellationToken);
}

View File

@ -0,0 +1,17 @@
using Application.Classes;
using Application.DataTransferObjects.User;
namespace Application.Interfaces;
public interface IUserRepository
{
Task<Result<List<UserDto>>> GetAllianceUsersAsync(Guid allianceId, CancellationToken cancellationToken);
Task<Result<UserDto>> GetUserAsync(Guid userId, CancellationToken cancellationToken);
Task<Result> ChangeUserPasswordAsync(ChangePasswordDto changePasswordDto, CancellationToken cancellationToken);
Task<Result<UserDto>> UpdateUserAsync(UpdateUserDto updateUserDto, CancellationToken cancellationToken);
Task<Result> DeleteUserAsync(Guid userId, CancellationToken cancellationToken);
}

View File

@ -0,0 +1,9 @@
using Application.Classes;
using Application.DataTransferObjects.VsDuelParticipant;
namespace Application.Interfaces;
public interface IVsDuelParticipantRepository
{
Task<Result<VsDuelParticipantDto>> UpdateVsDuelParticipant(VsDuelParticipantDto vsDuelParticipantDto, CancellationToken cancellationToken);
}

View File

@ -7,11 +7,13 @@ public interface IVsDuelRepository
{
Task<Result<VsDuelDto>> GetVsDuelAsync(Guid vsDuelId, CancellationToken cancellationToken);
Task<Result<List<VsDuelDto>>> GetPlayerVsDuelsAsync(Guid playerId, CancellationToken cancellationToken);
Task<Result<VsDuelDetailDto>> GetVsDuelDetailAsync(Guid vsDuelId, CancellationToken cancellationToken);
Task<Result<VsDuelDto>> CreateVsDuelAsync(CreateVsDuelDto createVsDuelDto, CancellationToken cancellationToken);
Task<Result<List<VsDuelDto>>> GetAllianceVsDuelsAsync(Guid allianceId, int take, CancellationToken cancellationToken);
Task<Result<VsDuelDto>> UpdateVsDuelAsync(UpdateVsDuelDto updateVsDuelDto, CancellationToken cancellationToken);
Task<Result<VsDuelDto>> CreateVsDuelAsync(CreateVsDuelDto createVsDuelDto, string createdBy, CancellationToken cancellationToken);
Task<Result<VsDuelDto>> UpdateVsDuelAsync(UpdateVsDuelDto updateVsDuelDto, string modifiedBy, CancellationToken cancellationToken);
Task<Result<bool>> DeleteVsDuelAsync(Guid vsDuelId, CancellationToken cancellationToken);
}

View File

@ -10,8 +10,11 @@ public class AdmonitionProfile : Profile
{
CreateMap<Admonition, AdmonitionDto>();
CreateMap<CreateAdmonitionDto, Admonition>();
CreateMap<CreateAdmonitionDto, Admonition>()
.ForMember(des => des.Id, opt => opt.MapFrom(src => Guid.CreateVersion7()))
.ForMember(des => des.CreatedOn, opt => opt.MapFrom(src => DateTime.Now));
CreateMap<UpdateAdmonitionDto, Admonition>();
CreateMap<UpdateAdmonitionDto, Admonition>()
.ForMember(des => des.ModifiedOn, opt => opt.MapFrom(src => DateTime.Now));
}
}

View File

@ -11,11 +11,12 @@ public class AllianceProfile : Profile
{
CreateMap<Alliance, AllianceDto>();
CreateMap<CreateAllianceDto, Alliance>();
CreateMap<UpdateAllianceDto, Alliance>()
.ForMember(des => des.ModifiedOn, opt => opt.MapFrom(src => DateTime.Now));
CreateMap<UpdateAllianceDto, Alliance>();
CreateMap<RegisterRequestDto, Alliance>()
CreateMap<SignUpRequestDto, Alliance>()
.ForMember(des => des.Id, opt => opt.MapFrom(src => Guid.CreateVersion7()))
.ForMember(des => des.CreatedOn, opt => opt.MapFrom(src => DateTime.Now))
.ForMember(des => des.Name, opt => opt.MapFrom(src => src.AllianceName))
.ForMember(des => des.Abbreviation, opt => opt.MapFrom(src => src.AllianceAbbreviation))
.ForMember(des => des.Server, opt => opt.MapFrom(src => src.AllianceServer));

View File

@ -8,7 +8,12 @@ public class AuthenticationProfile : Profile
{
public AuthenticationProfile()
{
CreateMap<RegisterRequestDto, User>()
CreateMap<SignUpRequestDto, User>()
.ForMember(des => des.Id, opt => opt.MapFrom(src => Guid.CreateVersion7()))
.ForMember(des => des.UserName, opt => opt.MapFrom(src => src.Email))
.ForMember(des => des.NormalizedEmail, opt => opt.MapFrom(src => src.Email.ToUpper()));
CreateMap<RegisterUserDto, User>()
.ForMember(des => des.UserName, opt => opt.MapFrom(src => src.Email))
.ForMember(des => des.NormalizedEmail, opt => opt.MapFrom(src => src.Email.ToUpper()));
}

View File

@ -0,0 +1,15 @@
using Application.DataTransferObjects.CustomEventParticipant;
using AutoMapper;
using Database.Entities;
namespace Application.Profiles;
public class CustomEventParticipantProfile : Profile
{
public CustomEventParticipantProfile()
{
CreateMap<CustomEventParticipant, CustomEventParticipantDto>()
.ForMember(des => des.Id, opt => opt.MapFrom(src => Guid.CreateVersion7()))
.ForMember(des => des.PlayerName, opt => opt.MapFrom(src => src.Player.PlayerName));
}
}

View File

@ -0,0 +1,21 @@
using Application.DataTransferObjects.CustomEvent;
using AutoMapper;
using Database.Entities;
namespace Application.Profiles;
public class CustomEventProfile : Profile
{
public CustomEventProfile()
{
CreateMap<CustomEvent, CustomEventDto>();
CreateMap<CreateCustomEventDto, CustomEvent>()
.ForMember(des => des.Id, opt => opt.MapFrom(src => Guid.CreateVersion7()))
.ForMember(des => des.EventDate, opt => opt.MapFrom(src => DateTime.Parse(src.EventDateString)));
CreateMap<UpdateCustomEventDto, CustomEvent>()
.ForMember(des => des.ModifiedOn, opt => opt.MapFrom(src => DateTime.Now))
.ForMember(des => des.EventDate, opt => opt.MapFrom(src => DateTime.Parse(src.EventDateString)));
}
}

View File

@ -0,0 +1,19 @@
using Application.DataTransferObjects.DesertStormParticipants;
using AutoMapper;
using Database.Entities;
namespace Application.Profiles;
public class DesertStormParticipantProfile : Profile
{
public DesertStormParticipantProfile()
{
CreateMap<DesertStormParticipant, DesertStormParticipantDto>()
.ForMember(des => des.PlayerName, opt => opt.MapFrom(src => src.Player.PlayerName));
CreateMap<CreateDesertStormParticipantDto, DesertStormParticipant>()
.ForMember(des => des.Id, opt => opt.MapFrom(src => Guid.CreateVersion7()));
CreateMap<UpdateDesertStormParticipantDto, DesertStormParticipant>();
}
}

View File

@ -8,12 +8,20 @@ public class DesertStormProfile : Profile
{
public DesertStormProfile()
{
CreateMap<DesertStorm, DesertStormDto>();
CreateMap<DesertStorm, DesertStormDto>()
.ForMember(des => des.Participants,
opt => opt.MapFrom(src => src.DesertStormParticipants.Count(p => p.Participated)));
CreateMap<UpdateDesertStormDto, DesertStorm>();
CreateMap<DesertStorm, DesertStormDetailDto>()
.ForMember(des => des.DesertStormParticipants, opt => opt.MapFrom(src => src.DesertStormParticipants))
.ForMember(des => des.Participants,
opt => opt.MapFrom(src => src.DesertStormParticipants.Count(p => p.Participated)));
CreateMap<UpdateDesertStormDto, DesertStorm>()
.ForMember(des => des.ModifiedOn, opt => opt.MapFrom(src => DateTime.Now));
CreateMap<CreateDesertStormDto, DesertStorm>()
.ForMember(des => des.Year, opt => opt.MapFrom(src => DateTime.Now.Year))
.ForMember(des => des.CalendarWeek, opt => opt.MapFrom(src => DateTime.Now.DayOfWeek));
.ForMember(des => des.Id, opt => opt.MapFrom(src => Guid.CreateVersion7()))
.ForMember(des => des.EventDate, opt => opt.MapFrom(src => DateTime.Parse(src.EventDate)));
}
}

Some files were not shown because too many files have changed in this diff Show More