public ActionResult DeleteB(long id, command_line command_line) { try { var tokenResponse = httpClient.DeleteAsync(baseAddress + "deleteByidc/" + id).Result; return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult EditB(command_line command_line) { try { var APIResponse = httpClient.PutAsJsonAsync <command_line>(baseAddress + "updatecommande_line/", command_line).ContinueWith(postTask => postTask.Result.EnsureSuccessStatusCode()); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create([Bind(Include = "id,amount,total_product_price,command_reference,product_id")] command_line command_line, long?command_reference, long?product_id) { httpClient.BaseAddress = new Uri("http://localhost:8081/ConsomiTounsi/"); httpClient.DefaultRequestHeaders.Accept.Clear(); var postTask = httpClient.PostAsJsonAsync <command_line>(baseAddress + "addCommand_line?id=" + command_line.command_reference + "&id=" + command_line.product_id, command_line); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(View(new command_line())); }