// ***********************************************************************
//
// HEATH
//
// ***********************************************************************
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
{
///
/// Handles mappings between
/// ,
/// and
///
public static class ModuleMapper
{
///
/// Maps the permissionRequest to ModuleAdapter.
///
/// The Module to be mapped.
/// A representing
/// the asynchronous execution of the service.
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,
};
}
}
}