profileShare

rasmusjy / splitapp-backend-microservices

Read-only snapshot

No repository description.

main default branch 501 files Expires Sep 13, 2026, 9:06 AM
AppUserBllDtoFactory.cs 928 bytes
1 using SplitApp.Shared.Contracts.Users;
2 using SplitApp.WebApp.Application.DTO;
3
4 namespace SplitApp.WebApp.Application.Mappers;
5
6 public static class AppUserBllDtoFactory
7 {
8 /// <summary>
9 /// Project the cross-service UserDto into the BLL shape used by views (which still
10 /// read FirstName/LastName separately for initials, etc.). DisplayName is split on
11 /// the first space — fidelity loss with 3-part names is acceptable for display.
12 /// </summary>
13 public static AppUserBllDto? Create(UserDto? dto)
14 {
15 if (dto is null) return null;
16 var display = dto.DisplayName ?? "";
17 var parts = display.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
18 return new AppUserBllDto
19 {
20 Id = dto.Id,
21 FirstName = parts.Length > 0 ? parts[0] : "",
22 LastName = parts.Length > 1 ? parts[1] : "",
23 Email = dto.Email,
24 };
25 }
26 }
27