// GET: Category/Edit/5 public async Task <ActionResult> Edit(int id) { var model = new CategoryBindingViewModels(); var response = await _clientHelper.GetCategory(id); if (response.IsSuccessStatusCode) { model = await response.Content.ReadAsAsync <CategoryBindingViewModels>(); } return(View(model)); }
public async Task <ActionResult> Edit(int id, CategoryBindingViewModels model) { try { var response = await _clientHelper.UpdateCategory(id, model); if (response.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(View(model)); } catch { return(View()); } }
public async Task <ActionResult> Create(CategoryBindingViewModels model) { try { var response = await _clientHelper.InsertCategory(model); if (response.IsSuccessStatusCode) { return(RedirectToAction("Index")); } else { return(View()); } } catch { return(View()); } }
public async Task <HttpResponseMessage> InsertCategory(CategoryBindingViewModels model) { return(await _client.PostAsJsonAsync("api/Category", model)); }
public async Task <HttpResponseMessage> UpdateCategory(int id, CategoryBindingViewModels model) { return(await _client.PutAsJsonAsync($"api/Category/{model.id}/", model)); }