public async Task <ActionResult> Create(CreateKullaniciViewModel kullaniciResource) { if (kullaniciResource.Pasword != null || kullaniciResource.Pasword != "") { kullaniciResource.Pasword = Utilities.EnDec.Encryption(kullaniciResource.Pasword); } if (ModelState.IsValid) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(apiBaseAddress); var httpResponse = await client.PostAsJsonAsync("Kullanici", kullaniciResource); if (httpResponse.IsSuccessStatusCode) { return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, "Server error."); } } } return(View(kullaniciResource)); }
public async Task <ActionResult> Edit(int id, CreateKullaniciViewModel kullaniciResource) { if (kullaniciResource.Pasword != null || kullaniciResource.Pasword != "") //TO-DO: Daha mantıklı password validation { kullaniciResource.Pasword = Utilities.EnDec.Encryption(kullaniciResource.Pasword); } if (ModelState.IsValid) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(apiBaseAddress); var httpResponse = await client.PutAsJsonAsync($"Kullanici/{id}", kullaniciResource); if (httpResponse.IsSuccessStatusCode) { return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, "Server error try after some time."); } } return(RedirectToAction("Index")); } return(View(kullaniciResource)); }
public async Task <ActionResult> Create() { ApiTransactions apiTransactions = new ApiTransactions(); IEnumerable <SirketViewModel> sirkets = await apiTransactions.tumSirketleriGetir(); IEnumerable <GorevViewModel> gorevs = await apiTransactions.tumGorevleriGetir(); var model = new CreateKullaniciViewModel(); model.GorevViewModel = gorevs; model.SirketViewModel = sirkets; return(View(model)); }