refactor: devlist request handler, added static method for creating list

This commit is contained in:
jdevito
2023-02-01 11:50:26 -06:00
parent faaa2a354e
commit 4dc6d5b5ac
2 changed files with 26 additions and 23 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.Web
{
@@ -14,23 +15,34 @@ namespace PepperDash.Essentials.Core.Web
};
}
public static object MapToDeviceListObject(IKeyed device)
{
return new
{
Key = device.Key,
Name = (device is IKeyName)
? (device as IKeyName).Name
: "---"
};
}
public static object MapJoinToObject(string key, JoinMapBaseAdvanced join)
{
var kp = new KeyValuePair<string, JoinMapBaseAdvanced>(key, join);
return MapJoinToObject(kp);
}
public static object MapJoinToObject(KeyValuePair<string, JoinMapBaseAdvanced> join)
{
return new
{
DeviceKey = join.Key,
Joins = join.Value.Joins.Select(j => MapJoinDatacompleteToObject(j))
Joins = join.Value.Joins.Select(j => MapJoinDataCompleteToObject(j))
};
}
public static object MapJoinDatacompleteToObject(KeyValuePair<string, JoinDataComplete> joinData)
public static object MapJoinDataCompleteToObject(KeyValuePair<string, JoinDataComplete> joinData)
{
return new
{