Skip to content

Commit

Permalink
[TS-1501] extend AssetContract with additional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
LBHJHeppinstall committed Jul 9, 2024
1 parent 9844fd1 commit 2f7b84a
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 15 deletions.
20 changes: 17 additions & 3 deletions Hackney.Shared.HousingSearch/Domain/Asset/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,42 @@ namespace Hackney.Shared.HousingSearch.Domain.Asset
{
public class Contract
{
public static Contract Create(string id, string targetId, string targetType, IEnumerable<Charges> charges)
public static Contract Create(string id, string targetId, string targetType, DateTime? startDate, DateTime? approvalDate,
bool? isApproved, IEnumerable<Charges> charges, IEnumerable<RelatedPeople> relatedPeople)
{
return new Contract(
id,
targetId,
targetType,
charges
startDate,
approvalDate,
isApproved,
charges,
relatedPeople
);
}
public Contract() { }

private Contract(string id, string targetId, string targetType, IEnumerable<Charges> charges)
private Contract(string id, string targetId, string targetType, DateTime? startDate, DateTime? approvalDate,
bool? isApproved, IEnumerable<Charges> charges, IEnumerable<RelatedPeople> relatedPeople)
{
Id = id;
TargetId = targetId;
TargetType = targetType;
StartDate = startDate;
ApprovalDate = approvalDate;
IsApproved = isApproved;
Charges = charges;
RelatedPeople = relatedPeople;
}

public string Id { get; set; }
public string TargetId { get; set; }
public string TargetType { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? ApprovalDate { get; set; }
public bool? IsApproved { get; set; }
public IEnumerable<Charges> Charges { get; set; }
public IEnumerable<RelatedPeople> RelatedPeople { get; set; }
}
}
24 changes: 19 additions & 5 deletions Hackney.Shared.HousingSearch/Domain/Contract/Contract.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
using Hackney.Shared.HousingSearch.Domain.Contract;
using Hackney.Shared.HousingSearch.Gateways.Models.Contract;
using Hackney.Shared.HousingSearch.Gateways.Models.Contract;
using System;
using System.Collections.Generic;

namespace Hackney.Shared.HousingSearch.Domain.Contract
{
public class Contract
{
public static Contract Create(string id, string targetId, string targetType, IEnumerable<QueryableCharges> charges)
public static Contract Create(string id, string targetId, string targetType, DateTime? startDate, DateTime? approvalDate,
bool? isApproved, IEnumerable<QueryableCharges> charges, IEnumerable<QueryableRelatedPeople> relatedPeople)
{
return new Contract(
id,
targetId,
targetType,
charges
startDate,
approvalDate,
isApproved,
charges,
relatedPeople
);
}
public Contract() { }

private Contract(string id, string targetId, string targetType, IEnumerable<QueryableCharges> charges)
private Contract(string id, string targetId, string targetType, DateTime? startDate, DateTime? approvalDate,
bool? isApproved, IEnumerable<QueryableCharges> charges, IEnumerable<QueryableRelatedPeople> relatedPeople)
{
Id = id;
TargetId = targetId;
TargetType = targetType;
StartDate = startDate;
ApprovalDate = approvalDate;
IsApproved = isApproved;
TargetType = targetType;
Charges = charges;
RelatedPeople = relatedPeople;
}

public string Id { get; set; }
public string TargetId { get; set; }
public string TargetType { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? ApprovalDate { get; set; }
public bool? IsApproved { get; set; }
public IEnumerable<QueryableCharges> Charges { get; set; }
public IEnumerable<QueryableRelatedPeople> RelatedPeople { get; set; }
}
}
30 changes: 30 additions & 0 deletions Hackney.Shared.HousingSearch/Domain/Contract/RelatedPeople.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
using Nest;

namespace Hackney.Shared.HousingSearch.Domain.Contract
{
public class RelatedPeople
{
public RelatedPeople() { }

public static RelatedPeople Create(string id, string type, string subType, string name)
{
return new RelatedPeople(id, type, subType, name);
}

private RelatedPeople(string id, string type, string subType, string name)
{
Id = id;
Type = type;
SubType = subType;
Name = name;
}

public string Id { get; set; }
public string Type { get; set; }
public string SubType { get; set; }
public string Name { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Hackney.Shared.HousingSearch.Domain.Asset;
using Nest;
using Asset = Hackney.Shared.HousingSearch.Domain.Asset.Asset;

Expand Down Expand Up @@ -165,7 +163,11 @@ public Asset CreateAll()
AssetContract.Id,
AssetContract.TargetId,
AssetContract.TargetType,
AssetContract.Charges?.Select(p => p.Create()).ToList()
AssetContract.StartDate,
AssetContract.ApprovalDate,
AssetContract.IsApproved,
AssetContract.Charges?.Select(p => p.Create()).ToList(),
AssetContract.RelatedPeople?.Select(p => p.Create()).ToList()
);

return Asset.CreateAll(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
using Hackney.Shared.HousingSearch.Gateways.Models.Contract;
using System;
using Hackney.Shared.HousingSearch.Gateways.Models.Contract;
using Nest;
using System;
using System.Collections.Generic;
using System.Text;

namespace Hackney.Shared.HousingSearch.Gateways.Models.Assets
{
public class QueryableAssetContract
{
public Domain.Contract.Contract Create()
{
return Domain.Contract.Contract.Create(Id, TargetId, TargetType, Charges);
return Domain.Contract.Contract.Create(Id, TargetId, TargetType, StartDate, ApprovalDate, IsApproved,
Charges, RelatedPeople);
}

[Text(Name = "id")]
public string Id { get; set; }
public string TargetId { get; set; }
public string TargetType { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? ApprovalDate { get; set; }
public bool? IsApproved { get; set; }
public IEnumerable<QueryableCharges> Charges { get; set; }
public IEnumerable<QueryableRelatedPeople> RelatedPeople { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Hackney.Shared.HousingSearch.Domain.Contract;
using Nest;

namespace Hackney.Shared.HousingSearch.Gateways.Models.Contract
{
public class QueryableRelatedPeople
{
public RelatedPeople Create()
{
return RelatedPeople.Create(
Id,
Type,
SubType,
Name
);
}
[Text(Name = "id")]
public string Id { get; set; }
public string Type { get; set; }
public string SubType { get; set; }
public string Name { get; set; }
}
}

0 comments on commit 2f7b84a

Please sign in to comment.