public async Task <IActionResult> GetCodeSamples() { var items = await SampleParser.GetSamples(onlyMetaData : true); var categories = items.Select(cs => cs.Category).Distinct().ToList(); var grouped = new List <CodeSampleCategory>(); foreach (var cat in categories) { grouped.Add(new CodeSampleCategory { Category = cat, Samples = items.Where(cs => cs.Category == cat) }); } return(Json(grouped)); }
public async Task <IActionResult> GetCodeSample(string id) { var cs = (await SampleParser.GetSamples()).FirstOrDefault(s => s.Id == id); return(Json(cs)); }