// GET: Boxers/Create public ActionResult Create() { BoxersDetailsViewModel model = new BoxersDetailsViewModel(); ViewBag.Title = "Create"; return View(model); }
// GET: Boxers/Edit/5 public ActionResult Edit(int id) { var boxer = webClient.ExecuteGet<BoxerDto>(new Models.ApiRequest() { EndPoint = string.Format("boxers/{0}", id) }); BoxersDetailsViewModel model = new BoxersDetailsViewModel(); model.Name = boxer.Name; ViewBag.Title = "Edit"; return View("Create", model); }
public ActionResult Create(BoxersDetailsViewModel model) { try { object existingTest = webClient.ExecutePost<object>(new Models.ApiRequest() { EndPoint = string.Format("boxers"), Request = new BoxerDto() { Name = model.Name } }); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, BoxersDetailsViewModel model) { try { if (ModelState.IsValid) { try { var response = webClient.ExecutePut<object>(new Models.ApiRequest() { EndPoint = string.Format("boxers/{0}", model.Id), Request = new BoxerDto() { Name = model.Name } }); return RedirectToAction("Index"); } catch (Exception e) { ModelState.AddModelError("generalError", e.Message); return View(model); } } return View(model); } catch { return View(model); } }