// GET: Tasting/Edit/1
        public async Task <IActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            TastingDTO          dto    = new TastingDTO();
            HttpClient          client = _scotchesAPI.InitializeClient();
            HttpResponseMessage res    = await client.GetAsync("/api/tastings/" + id);

            if (res.IsSuccessStatusCode)
            {
                var result = res.Content.ReadAsStringAsync().Result;
                dto = JsonConvert.DeserializeObject <TastingDTO>(result);
            }

            //var WishList = dto.SingleOrDefault(m => m.wishListName == wishListName);
            if (dto == null)
            {
                return(NotFound());
            }

            return(View(dto));
        }
        // GET: Tastings/Details/5
        public async Task <IActionResult> Details(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            List <TastingDTO>   tastings = new List <TastingDTO>();
            HttpClient          client   = _scotchesAPI.InitializeClient();
            HttpResponseMessage res      = await client.GetAsync("/api/tastings");

            //Checking the response is successful or not which is sent using HttpClient
            if (res.IsSuccessStatusCode)
            {
                //Storing the response details recieved from web api
                var result = res.Content.ReadAsStringAsync().Result;
                //Deserializing the response recieved from web api and storing into the Employee list
                tastings = JsonConvert.DeserializeObject <List <TastingDTO> >(result);
            }

            if (tastings == null)
            {
                return(NotFound());
            }

            TastingDTO dto = tastings.Find(t => t._id == id);

            return(View(dto));
        }
        public IActionResult Create([Bind("distillerName,flavor,age,style,region,inStock,bottlingNotes,comment")] TastingDTO Tasting)
        {
            if (ModelState.IsValid)
            {
                HttpClient client = _scotchesAPI.InitializeClient();

                var content = new StringContent(JsonConvert.SerializeObject(Tasting, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                }), Encoding.UTF8, "application/json");
                HttpResponseMessage res = client.PostAsync("/api/tastings", content).Result;
                if (res.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(Tasting));
        }
        public IActionResult Edit(string id, [Bind("distillerName,flavor,age,style,region,inStock,bottlingNotes,comment,_id")] TastingDTO Tasting)
        {
            if (id != Tasting._id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                HttpClient client = _scotchesAPI.InitializeClient();

                var content             = new StringContent(JsonConvert.SerializeObject(Tasting), Encoding.UTF8, "application/json");
                HttpResponseMessage res = client.PutAsync("/api/tastings/" + id, content).Result;
                if (res.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(Tasting));
        }