public Model.Document Transition(IResourceUsageRightsTemplate rights) { Model.Document document = new Model.Document(); JArray jarray; try { document.Id = rights.Id; if (!string.IsNullOrEmpty(rights.Revision)) { document.Rev = rights.Revision; } document["Type"] = "resourceusagerightstemplate"; if (rights.UsageRights != null && rights.UsageRights.Count > 0) { jarray = new JArray(); for (int i = 0; i < rights.UsageRights.Count; i++) { JObject jobj = new JObject(); jobj.Add(new JProperty(rights.UsageRights[i].Entity, (int)rights.UsageRights[i].Permissions.Resource.Permissions)); jarray.Add(jobj); } document.Add("UsageRights", jarray); } } catch (Exception e) { Logger.Storage.Error("An exception occurred while attempting to parse the resource object.", e); throw; } return(document); }
public Model.Document Transition(IResourceUsageRightsTemplate rights) { Model.Document document = new Model.Document(); JArray jarray; try { document.Id = rights.Id; if (!string.IsNullOrEmpty(rights.Revision)) document.Rev = rights.Revision; document["Type"] = "resourceusagerightstemplate"; if (rights.UsageRights != null && rights.UsageRights.Count > 0) { jarray = new JArray(); for (int i = 0; i < rights.UsageRights.Count; i++) { JObject jobj = new JObject(); jobj.Add(new JProperty(rights.UsageRights[i].Entity, (int)rights.UsageRights[i].Permissions.Resource.Permissions)); jarray.Add(jobj); } document.Add("UsageRights", jarray); } } catch (Exception e) { Logger.Storage.Error("An exception occurred while attempting to parse the resource object.", e); throw; } return document; }