Skip to content

Commit

Permalink
refactor: rearrange properties to match domain class
Browse files Browse the repository at this point in the history
refactor: pass in entire identity to ctor
  • Loading branch information
NikolaVetnic committed Jan 24, 2024
1 parent 6363d66 commit f2b917a
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions Modules/Devices/src/Devices.Application/DTOs/IdentitySummaryDTO.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,43 @@
using Backbone.DevelopmentKit.Identity.ValueObjects;
using Backbone.Modules.Devices.Application.Devices.DTOs;
using Backbone.Modules.Devices.Application.Devices.DTOs;
using Backbone.Modules.Devices.Domain.Entities;

namespace Backbone.Modules.Devices.Application.DTOs;

public class IdentitySummaryDTO
{
public string Address { get; set; }
public string? ClientId { get; set; }
public byte[] PublicKey { get; set; }

public string TierId { get; set; }

public string Address { get; set; }
public byte[] PublicKey { get; set; }
public DateTime CreatedAt { get; set; }

public byte IdentityVersion { get; set; }

public IEnumerable<DeviceDTO> Devices { get; set; }
public int NumberOfDevices { get; set; }

public IEnumerable<DeviceDTO> Devices { get; set; }
public byte IdentityVersion { get; set; }

public IdentitySummaryDTO(IdentityAddress address, string? clientId, byte[] publicKey, byte identityVersion, DateTime createdAt, List<Device> devices, string tierId)
{
Address = address.ToString();
public string TierId { get; set; }

if (clientId != null)
ClientId = clientId;
public IdentitySummaryDTO(Identity identity)
{
ClientId = identity.ClientId;

PublicKey = publicKey;
IdentityVersion = identityVersion;
CreatedAt = createdAt;
Address = identity.Address.ToString();
PublicKey = identity.PublicKey;
CreatedAt = identity.CreatedAt;

Devices = devices.Select(it => new DeviceDTO()
Devices = identity.Devices.Select(it => new DeviceDTO()
{
CreatedAt = it.CreatedAt,
CreatedByDevice = it.CreatedByDevice,
Id = it.Id,
LastLogin = new LastLoginInformation { Time = it.User.LastLoginAt },
Username = it.User.UserName!
});
NumberOfDevices = identity.Devices.Count;

IdentityVersion = identity.IdentityVersion;

NumberOfDevices = devices.Count;
TierId = tierId;
TierId = identity.TierId;
}
}

0 comments on commit f2b917a

Please sign in to comment.