Skip to content

Commit

Permalink
Added AreaId and PatchId to the object
Browse files Browse the repository at this point in the history
  • Loading branch information
humulla committed Nov 16, 2023
1 parent ab4a280 commit 8f17c34
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 22 deletions.
2 changes: 2 additions & 0 deletions Hackney.Shared.Asset/Boundary/Response/AssetResponseObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class AssetResponseObject
{
public Guid Id { get; set; }
public string AssetId { get; set; }
public Guid? AreaId { get; set; }
public Guid? PatchId { get; set; }
public AssetType AssetType { get; set; }
public RentGroup? RentGroup { get; set; }
public string RootAsset { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Hackney.Shared.Asset/Domain/Asset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class Asset
{
public Guid Id { get; set; }
public string AssetId { get; set; }
public Guid? AreaId { get; set; }
public Guid? PatchId { get; set; }
public AssetType AssetType { get; set; }
public RentGroup? RentGroup { get; set; }
public string RootAsset { get; set; }
Expand Down
48 changes: 26 additions & 22 deletions Hackney.Shared.Asset/Factories/EntityFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public static AssetDomain ToDomain(this AssetDb databaseEntity)
{
Id = databaseEntity.Id,
AssetId = databaseEntity.AssetId,
AreaId = databaseEntity.AreaId,
PatchId = databaseEntity.PatchId,
AssetType = databaseEntity.AssetType,
RentGroup = databaseEntity.RentGroup,
RootAsset = databaseEntity.RootAsset,
Expand All @@ -32,6 +34,30 @@ public static AssetDomain ToDomain(this AssetDb databaseEntity)
};
}

public static AssetDb ToDatabase(this AssetDomain domain)
{
if (domain == null) return null;
return new AssetDb
{
Id = domain.Id,
AssetId = domain.AssetId,
AreaId = domain.AreaId,
PatchId = domain.PatchId,
AssetType = domain.AssetType,
RentGroup = domain.RentGroup,
RootAsset = domain.RootAsset,
IsActive = domain.IsActive,
ParentAssetIds = domain.ParentAssetIds,
BoilerHouseId = domain.BoilerHouseId,
AssetLocation = domain.AssetLocation,
AssetAddress = domain.AssetAddress,
AssetManagement = domain.AssetManagement,
AssetCharacteristics = domain.AssetCharacteristics.ToDatabase(),
Tenure = domain.Tenure.ToDatabase(),
VersionNumber = domain.VersionNumber,
};
}

# region Asset Characteristics
public static AssetCharacteristics ToDomain(this AssetCharacteristicsDb databaseEntity)
{
Expand Down Expand Up @@ -139,28 +165,6 @@ public static AssetTenure ToDomain(this AssetTenureDb databaseEntity)
};
}

public static AssetDb ToDatabase(this AssetDomain domain)
{
if (domain == null) return null;
return new AssetDb
{
Id = domain.Id,
AssetId = domain.AssetId,
AssetType = domain.AssetType,
RentGroup = domain.RentGroup,
RootAsset = domain.RootAsset,
IsActive = domain.IsActive,
ParentAssetIds = domain.ParentAssetIds,
BoilerHouseId = domain.BoilerHouseId,
AssetLocation = domain.AssetLocation,
AssetAddress = domain.AssetAddress,
AssetManagement = domain.AssetManagement,
AssetCharacteristics = domain.AssetCharacteristics.ToDatabase(),
Tenure = domain.Tenure.ToDatabase(),
VersionNumber = domain.VersionNumber,
};
}

public static AssetTenureDb ToDatabase(this AssetTenure domain)
{
if (domain == null) return null;
Expand Down
2 changes: 2 additions & 0 deletions Hackney.Shared.Asset/Factories/ResponseFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public static AssetResponseObject ToResponse(this AssetDomain domain)
{
Id = domain.Id,
AssetId = domain.AssetId,
AreaId = domain.AreaId,
PatchId = domain.PatchId,
AssetType = domain.AssetType,
RentGroup = domain.RentGroup,
RootAsset = domain.RootAsset,
Expand Down
6 changes: 6 additions & 0 deletions Hackney.Shared.Asset/Infrastructure/AssetDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public class AssetDb
[DynamoDBProperty]
public string AssetId { get; set; }

[DynamoDBProperty]
public Guid? AreaId { get; set; }

[DynamoDBProperty]
public Guid? PatchId { get; set; }

[DynamoDBProperty(Converter = typeof(DynamoDbEnumConverter<AssetType>))]
public AssetType AssetType { get; set; }

Expand Down

0 comments on commit 8f17c34

Please sign in to comment.