public virtual IActionResult GetCompetencyContext([FromRoute] string sourceId) { CompetencyContextData data = new CompetencyContextData(_connectionString); if (!sourceId.Contains('.')) { return(new BadRequestResult()); } string[] sourceValues = sourceId.Split('.'); ObjectResult result = null; switch (sourceValues[0]) { case "COURSE": Course course = data.GetCourse(sourceValues[1]); if (course != null) { var example = CompetencyContextSetMapper.Map(course).ToJson(); result = new ObjectResult(example); } break; case "CREDENTIAL": Credential cred = data.GetCredential(sourceValues[1]); if (cred != null) { var example = CompetencyContextSetMapper.Map(cred).ToJson(); result = new ObjectResult(example); } break; case "ORGANIZATION": Organization org = data.GetOrganization(sourceValues[1]); if (org != null) { var example = CompetencyContextSetMapper.Map(org).ToJson(); result = new ObjectResult(example); } break; } if (result == null) { return(new NotFoundObjectResult(sourceId)); } return(result); }
public virtual IActionResult GetAllCFDocuments() { int? limit = 100; int? offset = 0; string filter = string.Empty; CompetencyContextData data = new CompetencyContextData(_connectionString); CFDocumentSetType example = null; if (!string.IsNullOrEmpty(filter)) { string[] filters = filter.Split('='); if (filters.Length == 2) { switch (filters[1]) { case "COURSE": List <Course> courses = data.GetCourses(limit ?? 100, offset ?? 0); example = CFDocumentSetMapper.Map(courses); break; case "ORGANIZATION": List <Organization> orgs = data.GetOrganizations(limit ?? 100, offset ?? 0); example = CFDocumentSetMapper.Map(orgs); break; case "CREDENTIAL": List <Credential> creds = data.GetCredentials(limit ?? 100, offset ?? 0); example = CFDocumentSetMapper.Map(creds); break; } } } if (example == null) { List <Course> courses = data.GetCourses(limit ?? 100, offset ?? 0); example = CFDocumentSetMapper.Map(courses); } return(new ObjectResult(example)); }