public static void Handle(UserSecurityContext user, string method, HttpContext context, CancellationToken cancel) { if (context.Request.Method == "POST") { if (method.Equals("all", StringComparison.OrdinalIgnoreCase)) { Get(user, context, cancel); return; } else if (method.Equals("find", StringComparison.OrdinalIgnoreCase)) { try { TaxaDomainUnitTypeProviderBase dutprovider = TaxonomyManager.Instance.GetTaxaDomainUnitTypeProvider(user); TaxaDomainProviderBase domprovider = TaxonomyManager.Instance.GetTaxaDomainProvider(user); JToken token = JsonUtils.GetDataPayload(context.Request); JArray junittypes = null; if (dutprovider != null && domprovider != null && token != null) { CompoundIdentity domainId = JsonUtils.ToId(token["domainid"]); TaxaDomain domain = domprovider.Get(domainId); if (domain != null) { IEnumerable <TaxaUnitType> units = dutprovider.GetTaxaUnitTypeByDomain(domain); junittypes = Jsonifier.ToJson(units); } if (junittypes != null) { RestUtils.Push(context.Response, JsonOpStatus.Ok, junittypes.ToString()); } else { RestUtils.Push(context.Response, JsonOpStatus.Ok, "[]"); } return; } RestUtils.Push(context.Response, JsonOpStatus.Failed); return; } catch { RestUtils.Push(context.Response, RestUtils.JsonOpStatus(JsonOpStatus.Failed)); return; } } } context.Response.StatusCode = HttpStatusCodes.Status400BadRequest; }
static void RetrieveTaxaDomainUnitType(UserSecurityContext context) { TaxaDomainUnitTypeProviderBase prov = TaxonomyManager.Instance.GetTaxaDomainUnitTypeProvider(context); var taxaDomainUnitType = prov.GetTaxaUnitTypeByDomain( new TaxaDomain( new CompoundIdentity(new Guid("E578CA70-6CEC-4961-BB43-14FD45F455BD"), new Guid("56852d24-6d70-4028-83eb-a874db291cbe")), new CompoundIdentity(new Guid("E578CA70-6CEC-4961-BB43-14FD45F455BD"), new Guid("7497d1c2-a83b-4975-b341-855d1317afc2")), "Bacteria")); foreach (var taxa in taxaDomainUnitType) { Console.WriteLine("TaxaUnitType: " + taxa.Name + ", " + taxa.Identity.Identity); } Console.WriteLine("Retrieve TaxaDomainUnitType Successful!"); }