コード例 #1
0
        public string listofbeers([FromBody] JObject BeerNa)
        {
            string OutPutVVar = string.Empty;

            string BeerName = BeerNa["BeerName"].ToString();

            BeerName = BeerName.ToLower().Trim();
            if (BeerName == "")
            {
                return("Invalid Beer name");
            }
            DataManupulation dfdsfsd  = new DataManupulation();
            IList <BeerInfo> sdsadasd = dfdsfsd.GetAllLList("https://api.punkapi.com/v2/beers", BeerName);

            if (sdsadasd != null && sdsadasd.Count > 0)
            {
                int idBeer    = sdsadasd[0].id;
                var beerddata = dfdsfsd.GetUserDetails(idBeer);

                BeerInfo sadasd = new BeerInfo();
                sadasd.id = idBeer;

                sadasd.name        = sdsadasd[0].name;
                sadasd.description = sdsadasd[0].description;
                sadasd.userRatings = beerddata;
                var dssd = new JavaScriptSerializer().Serialize(sadasd);

                return(dssd);
            }
            else
            {
                return("Invalid Beer name");
            }
        }
コード例 #2
0
        public string listofbeersByID(int id)
        {
            if (id == 0)
            {
                return("Invalid Beer ID");
            }


            DataManupulation dfdsfsd = new DataManupulation();
            string           vgd     = "https://api.punkapi.com/v2/beers/" + id;
            var BeerData             = dfdsfsd.start_get(vgd);

            if (BeerData.Status)
            {
                var beerddata = dfdsfsd.GetUserDetails(id);

                BeerInfo sadasd = new BeerInfo();
                sadasd.id          = id;
                sadasd.name        = BeerData.BeetInfoData.name;
                sadasd.description = BeerData.BeetInfoData.description;
                sadasd.userRatings = beerddata;
                var dssd = new JavaScriptSerializer().Serialize(sadasd);

                return(dssd);
            }
            else
            {
                return("Invalid Beer ID");
            }
        }