public async Task <IHttpActionResult> List(string query = null) { return(JsonWithPermissions(new { Results = await TestsDao.Find(this, query) })); }
public async Task <IHttpActionResult> Delete(string testId) { var result = await TestsDao.Delete(this, testId); if (result == null) { return(NotFound()); } return(JsonWithPermissions(result)); }
public async Task <IHttpActionResult> Update(string testId, TestsEditViewModel model) { var test = await TestsDao.Read(this, testId); if (test == null) { return(NotFound()); } var result = await TestsDao.Update(this, test, model); return(JsonWithPermissions(result)); }
public async Task <ActionResult> ConfirmDelete(Test test) { if (test != null) { try { await TestsDao.Delete(this, test); } catch (Exception) { return(RedirectToAction("Delete", new { test = test.TestId, cannotDelete = true })); } } return(RedirectToAction("Index")); }
public async Task <ActionResult> Index(string query = null) { var results = await TestsDao.Find(this, query); if (results.Count == 0 && string.IsNullOrWhiteSpace(query)) { results = null; } var model = new TestsSearchViewModel { Query = query, Results = results }; return(View(model)); }
public async Task <ActionResult> Create(TestsCreateViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { await TestsDao.Create(this, model); } catch (Exception e) { ModelState.AddModelError("", e); return(View(model)); } return(RedirectToAction("Details", new { test = model.TestId })); }
public async Task <ActionResult> Edit(Test test, TestsEditViewModel model) { if (test == null) { return(RedirectToAction("Index")); } if (!ModelState.IsValid) { return(View(model)); } try { await TestsDao.Update(this, test, model); } catch (Exception e) { ModelState.AddModelError("", e); return(View(model)); } return(RedirectToAction("Details", new { test = test.TestId })); }
public async Task <IHttpActionResult> Create(TestsCreateViewModel model) { return(JsonWithPermissions(await TestsDao.Create(this, model))); }