public ActionResult <CatCard> GetRandomCat() { CatCard card = new CatCard(); card.CatFact = catFactService.GetFact().Text; card.ImgUrl = catPicService.GetPic().File; return(card); }
public ActionResult <CatCard> GetRandomCard() { CatFact fact = catFactService.GetFact(); CatPic pic = catPicService.GetPic(); CatCard card = new CatCard() { CatFact = fact.Text, ImgUrl = pic.File }; return(card); }
public ActionResult <CatCard> CreateRandomCard() { CatCard c = new CatCard(); CatPic pic = catPicService.GetPic(); CatFact fact = catFactService.GetFact(); //create pic and fact objects if (fact == null || pic == null)//fact or pic == null; status code 500 { return(StatusCode(500)); } c.CatFact = fact.Text; c.ImgUrl = pic.File; return(Ok(c)); }
public ActionResult <CatCard> GetRandomCatCard() { try { CatFact fact = catFactService.GetFact(); CatPic pic = catPicService.GetPic(); CatCard card = new CatCard() { CatFact = fact.Text, ImgUrl = pic.File }; return(Ok(card)); } catch (Exception e) { return(BadRequest(e.Message)); } }