43 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| // ***********************************************************************
 | |
| // <copyright file="ModuleMapper.cs">
 | |
| //    AgileWebs
 | |
| // </copyright>
 | |
| // ***********************************************************************
 | |
| using Core.Thalos.Adapters;
 | |
| using Core.Thalos.Domain.Contexts.Onboarding.Request;
 | |
| using Microsoft.AspNetCore.Http;
 | |
| using MongoDB.Bson;
 | |
| using System.Security.Claims;
 | |
| namespace Core.Thalos.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,
 | |
|             };
 | |
|         }
 | |
|     }
 | |
| }
 | 
