public void Get_ReturnsOk() { var request = new LaunchpadFilterModel(); var response = _controller.Get(request).Result; Assert.IsInstanceOf(typeof(OkObjectResult), response); }
public async Task <IActionResult> Get([FromQuery] LaunchpadFilterModel filterRequest) { try { var launchpads = await _launchPadService.Get(filterRequest.Status, filterRequest.NameContains); var launchpadModels = launchpads.Select(x => new LaunchpadModel(x.Id, x.Name, x.Status)).ToList(); return(Ok(launchpadModels)); } //These 500 catches are redundant, but just an example exception handling, logging, and hopefully enhance readability //There are two logs created: one catchs all app info connected to Core's ILogger, and one captures only Api and explicit message concerns catch (Exception ex) { _logger.LogError(ex.Message); return(StatusCode(StatusCodes.Status500InternalServerError)); } }