Beispiel #1
0
        public ActionResult Edit(mvcEHContactModel contact)
        {
            var putTask = GlobalVariables.WebApiClient.PutAsJsonAsync <mvcEHContactModel>("EHContacts", contact);

            putTask.Wait();
            var result = putTask.Result;

            if (result.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            return(View(contact));
        }
Beispiel #2
0
        public ActionResult create(mvcEHContactModel EHContact)
        {
            var postTask = GlobalVariables.WebApiClient.PostAsJsonAsync <mvcEHContactModel>("EHContacts", EHContact);

            postTask.Wait();
            var result = postTask.Result;

            if (result.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
            return(View(EHContact));
        }
Beispiel #3
0
        public ActionResult Edit(int id)
        {
            mvcEHContactModel contact = null;
            var responseTask          = GlobalVariables.WebApiClient.GetAsync("EHContacts?id=" + id.ToString());

            responseTask.Wait();
            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsAsync <mvcEHContactModel>();
                readTask.Wait();
                contact = readTask.Result;
            }
            return(View(contact));
        }