public async Task <IActionResult> Delete(int id) { var commercants = new CommercantData(); HttpClient client = _api.Initial(); HttpResponseMessage res = await client.DeleteAsync($"api/commercants/{id}"); return(RedirectToAction("Index")); }
public async Task <CommercantData> Edit(CommercantData commercants) { HttpClient client = _api.Initial(); HttpResponseMessage response = await client.PutAsJsonAsync( $"api/commercants/{commercants.CommercantId}", commercants); response.EnsureSuccessStatusCode(); commercants = await response.Content.ReadAsAsync <CommercantData>(); return(commercants); }
public async Task <IActionResult> Edit(int id) { var commercants = new CommercantData(); HttpClient client = _api.Initial(); HttpResponseMessage res = await client.GetAsync($"api/commercants/{id}"); if (res.IsSuccessStatusCode) { var result = res.Content.ReadAsStringAsync().Result; commercants = JsonConvert.DeserializeObject <CommercantData>(result); } return(View(commercants)); }
public async Task <ActionResult <CommercantData> > Connexion_commercant(CommercantData commercants) { HttpClient client = _api.Initial(); //HttpPost HttpResponseMessage postTask = await client.GetAsync("api/commercants/LoginClient"); if (postTask.IsSuccessStatusCode) { return(View("Connexion_client", commercants)); } else { //return RedirectToAction("ListArticleUtilisateur", "Articles"); return(RedirectToAction("ListMarche", "Categories")); } }
public IActionResult Inscription_commercant(CommercantData commercants) { HttpClient client = _api.Initial(); //HttpPost var postTask = client.PostAsJsonAsync <CommercantData>("api/commercants", commercants); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } //ViewBag.categorieId = new SelectList(db.Categories, "categorieId", "Nom", categories.CategorieId); //ViewBag.smsid = new SelectList(db.Sms, "smsid", "smsid", categories.Smsid); return(View()); }