public async Task <ActionResult> Edit(int id) { SirketViewModel sirket = null; string imgBase64Data = ""; string imgDataURL = ""; using (var client = new HttpClient()) { client.BaseAddress = new Uri(apiBaseAddress); var httpResponse = await client.GetAsync($"Sirket/{id}"); if (httpResponse.IsSuccessStatusCode) { sirket = await httpResponse.Content.ReadAsAsync <SirketViewModel>(); imgBase64Data = Convert.ToBase64String(sirket.Logo); imgDataURL = string.Format("data:image/png;base64,{0}", imgBase64Data); ViewBag.ImageData = imgDataURL; } else { ModelState.AddModelError(string.Empty, "Server error."); } } if (sirket == null) { return(HttpNotFound()); } return(View(sirket)); }
public async Task <ActionResult> Details(int Id) { KullaniciViewModel kullanici = null; SirketViewModel sirket = null; GorevViewModel gorev = null; String sirketAdi = ""; String gorevAdi = ""; using (var client = new HttpClient()) { client.BaseAddress = new Uri(apiBaseAddress); var httpResponseKullanici = await client.GetAsync($"Kullanici/{Id}"); if (httpResponseKullanici.IsSuccessStatusCode) { kullanici = await httpResponseKullanici.Content.ReadAsAsync <KullaniciViewModel>(); var httpResponseSirket = await client.GetAsync($"Sirket/{kullanici.Sirket}"); if (httpResponseSirket.IsSuccessStatusCode) { sirket = await httpResponseSirket.Content.ReadAsAsync <SirketViewModel>(); sirketAdi = sirket.SirketAdi; ViewBag.SirketAdi = sirketAdi; } if (kullanici.Gorev != null) { var httpResponseGorev = await client.GetAsync($"Gorev/{kullanici.Gorev}"); if (httpResponseGorev.IsSuccessStatusCode) { gorev = await httpResponseGorev.Content.ReadAsAsync <GorevViewModel>(); gorevAdi = gorev.GorevAdi; ViewBag.GorevAdi = gorevAdi; } } } else { ModelState.AddModelError(string.Empty, "Server error."); } } if (kullanici == null) { return(HttpNotFound()); } return(View(kullanici)); }