public ActionResult Edit(int id) { var item = _appservice.GetItem(id); if (item == null) { return ItemNotFound("DataItem with id {0} does not exists!", id); } DataItemViewModel model = new DataItemViewModel(); model.Item = item; return View(model); }
public ActionResult Edit(int id, DataItemViewModel model) { if (ModelState.IsValid) { var item = _appservice.GetItem(id); if (item == null) { return ItemNotFound("DataItem with id {0} does not exists!", id); } _appservice.UpdateItem(model.Item); return RedirectToAction("Index"); } return View(model); }
public ActionResult Index() { DataItemViewModel model = new DataItemViewModel(); model.Data = _appservice.GetDataItems(); return View(model); }