public ResultDTO Test(MachineLearningDTO datas)
        {
            ResultDTO sonuc      = new ResultDTO();
            var       postResult = POST("http://localhost:5555/calculateaccuracy", datas);

            return(postResult);
        }
        public async Task <ActionResult> GenerateReorderInfo(MachineLearningDTO predictedDate)
        {
            using (var client = new HttpClient())
            {
                //http POST

                // send a POST request to the server uri with the data and get the response as HttpResponseMessage object
                // add 'Microsoft.AspNet.WebApi.Client' Nuget package
                HttpResponseMessage res = await client.PostAsJsonAsync("http://127.0.0.1:5000/", new { @InputYear = DateTime.Now.Year, @InputMonth = DateTime.Now.Month, @InputDay = DateTime.Now.Day });

                // Return the result from the server if the status code is 200 (everything is OK)
                // should raise exception or error if it's not
                if (res.IsSuccessStatusCode)
                {
                    // pass the result by setting the Viewdata property
                    // have to read as string for the data in response.body

                    List <Stationery> stationeries        = StationeryService.Instance.GetAllStationeries().ToList();
                    List <Stationery> updatedStationeries = new List <Stationery>();
                    JArray            jsonArray           = JArray.Parse(res.Content.ReadAsStringAsync().Result);
                    int i;
                    foreach (JArray ja in jsonArray)
                    {
                        i = 0;
                        int currentId = 0;
                        foreach (string a in ja)
                        {
                            if (i == 0)
                            {
                                currentId = Convert.ToInt32(a);
                                updatedStationeries.Add(stationeries.Find(x => x.Id == currentId));
                            }

                            if (i == 1)
                            {
                                int qty = Convert.ToInt32(a);
                                updatedStationeries.Find(x => x.Id == currentId).ReorderLevel    = qty;
                                updatedStationeries.Find(x => x.Id == currentId).ReorderQuantity = qty;
                            }

                            i = i + 1;
                        }
                    }
                    TempData["updatedStationeryQty"] = updatedStationeries;
                    ViewBag.data = updatedStationeries;
                    return(View(predictedDate));
                }
                else
                {
                    return(View("Error"));
                }
            }
        }
        private ResultDTO POST(string url, MachineLearningDTO datas)
        {
            string         resultStream = "";
            HttpWebRequest request      = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "POST";

            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            var jsonContent = JsonConvert.SerializeObject(datas);

            Byte[] byteArray = encoding.GetBytes(jsonContent);

            request.ContentLength = byteArray.Length;
            request.ContentType   = "application/json";

            using (Stream dataStream = request.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
            }
            long length = 0;

            try
            {
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    // got response

                    length = response.ContentLength;

                    using (Stream responseStream = response.GetResponseStream())
                    {
                        StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
                        resultStream = reader.ReadToEnd();
                        return(JsonConvert.DeserializeObject <ResultDTO>(resultStream));
                    }
                }
            }
            catch (WebException ex)
            {
                WebResponse errorResponse = ex.Response;
                using (Stream responseStream = errorResponse.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
                    resultStream = reader.ReadToEnd();
                    return(JsonConvert.DeserializeObject <ResultDTO>(resultStream));
                }
                throw;
            }
        }
        public JsonResult Test(MachineLearningDTO datas)
        {
            ResultDTO sonuc = _machineLearningManager.Test(datas);

            return(Json(new { Sonuc = sonuc.Result, Mesaj = sonuc.Message, Nesne = sonuc.Object }, JsonRequestBehavior.AllowGet));
        }