Beispiel #1
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");
            }
        }
Beispiel #2
0
        public string AddRatingBeer(IPRating RatingIP)
        {
            if (RatingIP.Id == 0)
            {
                return(StatusData("Faild", "Invalid Beer ID", RatingIP));
            }
            if (!(RatingIP.Rating > 0 && RatingIP.Rating < 6))
            {
                return(StatusData("Faild", "Invalid  Rating  it should be 1-5", RatingIP));
            }


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

            if (BeerData.Status)
            {
                RatingIP.Status  = "Sucess";
                RatingIP.BeeName = BeerData.BeetInfoData.name;
                dfdsfsd.AddBeerRating(RatingIP);
                var json = new JavaScriptSerializer().Serialize(RatingIP);
                return(json);
            }
            else
            {
                return(StatusData("Faild", "Invalid Beer ID", RatingIP));
            }
        }
        public void TestCaseForGetByID()
        {
            DataManupulation dfdsfsd = new DataManupulation();
            string           vgd     = "https://api.punkapi.com/v2/beers/1";
            var BeerData             = dfdsfsd.start_get(vgd);



            Assert.AreEqual(BeerData.Status, true);
            Assert.AreNotEqual(BeerData.Status, false);

            Assert.AreEqual(BeerData.BeetInfoData.name, "Buzz");

            Assert.AreNotEqual(BeerData.BeetInfoData.name, "KING fisher");
        }