public override async Task <IActionResult> HandleAsync(HttpRequest req, ILogger log) { try { AllRecordsResponseModel records = await _recordService.GetRecordsAsync(); var result = records .Records .GroupBy(r => r.Artist) .Select( gr => new { Artist = gr.Key, Titles = gr.ToList() .Select( t => new { song = t.Song, timestamp = t.Timestamp }) }); return(new ObjectResult(result) { StatusCode = 200 }); } catch (Exception e) { return(new ObjectResult(ErrorResponseModel.FromInternal(e.Message))); } }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "records")] HttpRequest req, ILogger log) { try { EndpointHandler handler = DependencyBootstrapper.Container.Resolve(typeof(SaveEndpointHandler)) as EndpointHandler; return(await handler.HandleAsync(req, log)); } catch (System.Exception e) { return(new ObjectResult(ErrorResponseModel.FromInternal(e.Message))); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "records")] HttpRequest req, ILogger log) { try { return(new ObjectResult(await new GetRecordsEndpointHandler().HandleAsync(req, log))); } catch (Exception e) { return(new ObjectResult(ErrorResponseModel.FromInternal(e.Message))); } }