示例#1
0
        public async Task <ActionResult> Edit(int id, CreateGorevViewModel gorevResource)
        {
            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(apiBaseAddress);
                    var httpResponse = await client.PutAsJsonAsync($"Kullanici/{id}", gorevResource);

                    if (httpResponse.IsSuccessStatusCode)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Server error try after some time.");
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(gorevResource));
        }
示例#2
0
        public async Task <ActionResult> Create(CreateGorevViewModel gorevResource)
        {
            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(apiBaseAddress);

                    var httpResponse = await client.PostAsJsonAsync("Gorev", gorevResource);

                    if (httpResponse.IsSuccessStatusCode)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Server error.");
                    }
                }
            }
            return(View(gorevResource));
        }