// GET: KinderGartenAdmin/Edit/5

        /* public ActionResult Edit(int id)
         * {
         *   return View();
         * }*/

        public ActionResult Edit(int id)
        {
            HttpClient        client            = new HttpClient();
            KinderGartenAdmin KinderGartenAdmin = null;

            client.BaseAddress = new Uri("http://localhost:8082");
            var responseTask = client.GetAsync("SpringMVC/servlet/retrieve-kinderGartenAdmin/" + id.ToString());

            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsAsync <KinderGartenAdmin>();

                KinderGartenAdmin = readTask.Result;
            }
            return(View(KinderGartenAdmin));
        }
        public async Task <ActionResult> Create(KinderGartenAdmin epm)
        {
            string Baseurl = "http://localhost:8082/";

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Baseurl);
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                // client.DefaultRequestHeaders.Add("X-Miva-API-Authorization", "MIVA xxxxxxxxxxxxxxxxxxxxxx");
                var response = await client.PostAsJsonAsync("SpringMVC/servlet/add-KinderGartenAdmin", epm);

                if (response.IsSuccessStatusCode)
                {
                    return(RedirectToAction("IndexKinderGartenAdmin"));
                }
            }
            return(View(epm));
        }
        /*public ActionResult Edit(int id, FormCollection collection)
         * {
         *  try
         *  {
         *      // TODO: Add update logic here
         *
         *      return RedirectToAction("Index");
         *  }
         *  catch
         *  {
         *      return View();
         *  }
         * }*/

        public ActionResult Edit(KinderGartenAdmin epm)
        {
            HttpClient        client            = new HttpClient();
            KinderGartenAdmin KinderGartenAdmin = null;

            client.BaseAddress = new Uri("http://localhost:8082");

            //HTTP POST
            var putTask = client.PutAsJsonAsync <KinderGartenAdmin>("SpringMVC/servlet/modify-KinderGartenAdmin", epm);

            putTask.Wait();

            var result = putTask.Result;

            if (result.IsSuccessStatusCode)
            {
                return(RedirectToAction("IndexKinderGartenAdmin"));
            }
            return(View());
        }
        public async Task <ActionResult> authenticateKinderGartenAdmin(KinderGartenAdmin epm)
        {
            string Baseurl = "http://localhost:8082/";

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Baseurl);
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                // client.DefaultRequestHeaders.Add("X-Miva-API-Authorization", "MIVA xxxxxxxxxxxxxxxxxxxxxx");
                var response = await client.PostAsJsonAsync("SpringMVC/servlet/authenticateKinderGartenAdmin", epm);

                if (response.IsSuccessStatusCode)
                {
                    //var type = epm.formation;
                    string name         = epm.name;
                    User   User         = null;
                    var    responseTask = client.GetAsync("SpringMVC/servlet/getUserByName/" + name.ToString());

                    var result = responseTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        var readTask = result.Content.ReadAsAsync <User>();

                        User = readTask.Result;
                    }

                    Session["UserConnecte"]     = User;
                    Session["UserConnecteId"]   = User.idUser;
                    Session["UserConnecteName"] = User.name;

                    return(RedirectToAction("IndexKinderGartenAdmin"));

                    //return View(Details);
                }
            }
            return(View(epm));
        }