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 CatCard GetRandomCatCard() { CatFact fact = GetFact(); CatPic pic = GetPic(); if (fact == null || pic == null) { return(null); } CatCard card = new CatCard() { CatFact = fact.Text, ImgUrl = pic.File }; return(card); }
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)); } }
public ActionResult <CatCard> GetRandomCard() { CatFactService serviceFact = new CatFactService(); CatPicService servicePic = new CatPicService(); CatCard card = new CatCard(); CatFact fact = serviceFact.GetFact(); CatPic pic = servicePic.GetPic(); if (fact == null || pic == null) { return(StatusCode(500)); } card.CatFact = fact.Text; card.ImgUrl = pic.File; return(Ok(card)); }