Skip to content

Instantly share code, notes, and snippets.

@n3dst4
Created October 8, 2012 15:23
Show Gist options
  • Save n3dst4/3853093 to your computer and use it in GitHub Desktop.
Save n3dst4/3853093 to your computer and use it in GitHub Desktop.
public string ZoneDataJSON
{
get
{
var newCount = 0L;
if (EntityInstance.IsNew()) return BlankZoneDataJSON;
var members = IoCContainer.Resolve<IZoneService>().
GetImmediateZoneMembers(this.EntityId).ToList<IZoneMember>().
Select(mem => new
{
id = mem.ZoneMemberId,
type = GetZoneMemberTypeName(mem.TableCatalogId),
entityId = GetMemberId(mem.EntityPrimaryKeyId, ref newCount),
pathData = mem.PathData,
transformation = mem.Transformation
}).ToArray();
return new JavaScriptSerializer().Serialize(new
{
floorPlanId = this.EntityInstance.ConceptDocumentId,
members = members
});
}
}
private long GetMemberId(long entityPrimaryKeyId, ref long newCount)
{
if (entityPrimaryKeyId <= 0)
{
if (entityPrimaryKeyId < newCount)
newCount = entityPrimaryKeyId;
else
entityPrimaryKeyId = --newCount;
}
return entityPrimaryKeyId;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment