public async Task <ActionResult <DayFix> > PostDayFix() { var dayFix = new DayFix(); // to create a new dayfix, we will make requests use our API intergrations try { var catApiService = new CatAPIService(); dayFix.CatImage = catApiService.GetRandomCatImage(); var jokeApiService = new JokeAPIService(); dayFix.DadJoke = jokeApiService.GetRandomJoke(); // if the dayfix object wasn't properly formed, return an error if (string.IsNullOrEmpty(dayFix.CatImage) || string.IsNullOrEmpty(dayFix.DadJoke)) { return(StatusCode(StatusCodes.Status500InternalServerError)); } } catch { return(StatusCode(StatusCodes.Status500InternalServerError)); } _context.DayFixes.Add(dayFix); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDayFix", new { id = dayFix.Id }, dayFix)); }
public void TestaCatAPIService() { var svc = new CatAPIService(); var GetImagemCategoriaChapeu = svc.GetImagemCategoriaChapeu(3); var GetImagemCategoriaOculos = svc.GetImagemCategoriaOculos(3); var GetListaCategorias = svc.GetListaCategorias(); var GetListaImagemRaca = svc.GetListaImagemRaca("sibe", 3); var GetListaRacaEspecifica = svc.GetListaRacaEspecifica("box"); var GetListaRacas = svc.GetListaRacas(); }