示例#1
0
        public ActionResult <CatCard> GetRandomCat()
        {
            CatCard card = new CatCard();

            card.CatFact = catFactService.GetFact().Text;
            card.ImgUrl  = catPicService.GetPic().File;
            return(card);
        }
示例#2
0
        public ActionResult <CatCard> GetRandomCard()
        {
            CatFact fact = catFactService.GetFact();
            CatPic  pic  = catPicService.GetPic();

            CatCard card = new CatCard()
            {
                CatFact = fact.Text,
                ImgUrl  = pic.File
            };

            return(card);
        }
示例#3
0
        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));
            }
        }