#region ========================================================================= USING ===================================================================================== using Lumina.Contracts.Responses.FileSystemManagement.Common; using Lumina.Contracts.Responses.FileSystemManagement.Files; using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities; using System.Collections.Generic; using System.Linq; #endregion namespace Lumina.Application.Common.Mapping.FileSystemManagement.Files; /// /// Extension methods for converting . /// public static class FileMapping { /// /// Converts to . /// /// The domain entity to be converted. /// The converted response. public static FileSystemTreeNodeResponse ToFileSystemTreeNodeResponse(this File domainEntity) { return new FileSystemTreeNodeResponse() { Name = domainEntity.Name, Path = domainEntity.Id.Path, ItemType = domainEntity.Type, IsHidden = domainEntity.IsHidden, IsExpanded = false, ChildrenLoaded = false }; } /// /// Converts to a collection of . /// /// The domain entities to be converted. /// The converted responses. public static IEnumerable ToFileSystemTreeNodeResponses(this IEnumerable domainEntities) { return domainEntities.Select(domainEntity => domainEntity.ToFileSystemTreeNodeResponse()); } /// /// Converts to . /// /// The domain entity to be converted. /// The converted response. public static FileResponse ToResponse(this File domainEntity) { return new FileResponse( domainEntity.Id.Path, domainEntity.Name, domainEntity.DateCreated.HasValue ? domainEntity.DateCreated.Value : default, domainEntity.DateModified.HasValue ? domainEntity.DateModified.Value : default, domainEntity.Size, domainEntity.IsHidden ); } /// /// Converts to a collection of . /// /// The domain entities to be converted. /// The converted responses. public static IEnumerable ToResponses(this IEnumerable domainEntities) { return domainEntities.Select(domainEntity => domainEntity.ToResponse()); } }