예제 #1
0
        public ActionResult Edit(int id)
        {
            string url = "ClasseData/FindClasse/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                Classe SelectedPlayer = response.Content.ReadAsAsync <Classe>().Result;
                return(View(SelectedPlayer));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
예제 #2
0
        public ActionResult Delete(int id)
        {
            //Getting the Classe which ID is given
            string url = "ClasseData/FindClasse/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                Classe SelectedClasse = response.Content.ReadAsAsync <Classe>().Result;
                return(View(SelectedClasse));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
예제 #3
0
        public ActionResult Edit(int id, Classe currentClasse)
        {
            //Update and save the Classe which ID is given
            string url = "ClasseData/UpdateClasse/" + id;

            HttpContent content = new StringContent(jss.Serialize(currentClasse));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Details", new { id = id }));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
예제 #4
0
        public ActionResult Create(Classe newClasse)
        {
            //Saving the new Classe object to the database
            string      url     = "ClasseData/AddClasse";
            HttpContent content = new StringContent(jss.Serialize(newClasse));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            if (response.IsSuccessStatusCode)
            {
                //Go back to classes list
                return(RedirectToAction("ClasseList"));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }