Add project files.

This commit is contained in:
Sergio Matias Urquin
2025-04-29 18:55:44 -06:00
commit c34987797a
46 changed files with 3697 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
// ***********************************************************************
// <copyright file="ModuleMapper.cs">
// HEATH
// </copyright>
// ***********************************************************************
using Core.Cerberos.Adapters;
using Core.Cerberos.Domain.Contexts.Onboarding.Request;
using Microsoft.AspNetCore.Http;
using MongoDB.Bson;
using System.Security.Claims;
namespace Core.Cerberos.Domain.Contexts.Onboarding.Mappers
{
/// <summary>
/// Handles mappings between
/// <see cref="ModuleRequest"/>,
/// and <see cref="ModuleAdapter"/>
/// </summary>
public static class ModuleMapper
{
/// <summary>
/// Maps the permissionRequest to ModuleAdapter.
/// </summary>
/// <param name="newModule">The Module to be mapped.</param>
/// <returns>A <see cref="ModuleAdapter"/> representing
/// the asynchronous execution of the service.</returns>
public static ModuleAdapter ToAdapter(this ModuleRequest newModule, IHttpContextAccessor httpContextAccessor)
{
return new ModuleAdapter
{
Id = ObjectId.GenerateNewId().ToString(),
Name = newModule.Name,
Description = newModule.Description,
Icon = newModule.Icon,
Route = newModule.Route,
Order = newModule.Order,
Application = newModule.Application,
CreatedAt = DateTime.UtcNow,
CreatedBy = httpContextAccessor.HttpContext?.User?.FindFirst(ClaimTypes.Email)?.Value ?? string.Empty,
};
}
}
}

View File

@@ -0,0 +1,39 @@
// ***********************************************************************
// <copyright file="PermissionMapper.cs">
// HEATH
// </copyright>
// ***********************************************************************
using Core.Cerberos.Adapters;
using Core.Cerberos.Domain.Contexts.Onboarding.Request;
using Microsoft.AspNetCore.Http;
using MongoDB.Bson;
using System.Security.Claims;
namespace Core.Cerberos.Domain.Contexts.Onboarding.Mappers
{
/// <summary>
/// Handles mappings between
/// <see cref="PermissionRequest"/>,
/// and <see cref="PermissionAdapter"/>
/// </summary>
public static class PermissionMapper
{
/// <summary>
/// Maps the permissionRequest to PermissionAdapter.
/// </summary>
/// <param name="newPermission">The Permission to be mapped.</param>
/// <returns>A <see cref="PermissionAdapter"/> representing
/// the asynchronous execution of the service.</returns>
public static PermissionAdapter ToAdapter(this PermissionRequest newPermission, IHttpContextAccessor httpContextAccessor)
{
return new PermissionAdapter
{
Id = ObjectId.GenerateNewId().ToString(),
Name = newPermission.Name,
Description = newPermission.Description,
CreatedAt = DateTime.UtcNow,
CreatedBy = httpContextAccessor.HttpContext?.User?.FindFirst(ClaimTypes.Email)?.Value ?? string.Empty,
AccessLevel = newPermission.AccessLevel
};
}
}
}

View File

@@ -0,0 +1,42 @@
// ***********************************************************************
// <copyright file="RoleMapper.cs">
// HEATH
// </copyright>
// ***********************************************************************
using Core.Cerberos.Adapters;
using Core.Cerberos.Domain.Contexts.Onboarding.Request;
using Microsoft.AspNetCore.Http;
using MongoDB.Bson;
using System.Security.Claims;
namespace Core.Cerberos.Domain.Contexts.Onboarding.Mappers
{
/// <summary>
/// Handles mappings between
/// <see cref="RoleRequest"/>,
/// and <see cref="RoleAdapter"/>
/// </summary>
public static class RoleMapper
{
/// <summary>
/// Maps the RoleRequest to RoleAdapter.
/// </summary>
/// <param name="newRole">The Role to be mapped.</param>
/// <returns>A <see cref="RoleAdapter"/> representing
/// the asynchronous execution of the service.</returns>
public static RoleAdapter ToAdapter(this RoleRequest newRole, IHttpContextAccessor httpContextAccessor)
{
return new RoleAdapter
{
Id = ObjectId.GenerateNewId().ToString(),
Name = newRole.Name,
Description = newRole.Description,
Applications = newRole.Applications,
Modules = newRole.Modules,
Permissions = newRole.Permissions,
CreatedAt = DateTime.UtcNow,
CreatedBy = httpContextAccessor.HttpContext?.User?.FindFirst(ClaimTypes.Email)?.Value ?? string.Empty
};
}
}
}

View File

@@ -0,0 +1,46 @@
// ***********************************************************************
// <copyright file="UserMapper.cs">
// HEATH
// </copyright>
// ***********************************************************************
using Core.Cerberos.Adapters;
using Core.Cerberos.Domain.Contexts.Onboarding.Request;
using Microsoft.AspNetCore.Http;
using MongoDB.Bson;
using System.Security.Claims;
namespace Core.Cerberos.Domain.Contexts.Onboarding.Mappers
{
/// <summary>
/// Handles mappings between
/// <see cref="UserRequest"/>,
/// and <see cref="UserAdapter"/>
/// </summary>
public static class UserMapper
{
/// <summary>
/// Maps the UserRequest to UserAdapter.
/// </summary>
/// <param name="newUser">The User to be mapped.</param>
/// <returns>A <see cref="UserAdapter"/> representing
/// the asynchronous execution of the service.</returns>
public static UserAdapter ToAdapter(this UserRequest newUser, IHttpContextAccessor httpContextAccessor)
{
return new UserAdapter
{
Id = ObjectId.GenerateNewId().ToString(),
Guid = Guid.NewGuid().ToString(),
Email = newUser.Email,
Name = newUser.Name,
MiddleName = newUser.MiddleName,
LastName = newUser.LastName,
DisplayName = $"{newUser.Name} {newUser.MiddleName} {newUser.LastName}",
RoleId = newUser.RoleId,
Companies = newUser.Companies,
Projects = newUser.Projects,
CreatedAt = DateTime.UtcNow,
CreatedBy = httpContextAccessor.HttpContext?.User?.FindFirst(ClaimTypes.Email)?.Value ?? string.Empty
};
}
}
}