Skip to content

Instantly share code, notes, and snippets.

@n3dst4
Created October 8, 2012 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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