Ejemplo n.º 1
0
 public async Task <IHttpActionResult> List(string query = null)
 {
     return(JsonWithPermissions(new
     {
         Results = await TestsDao.Find(this, query)
     }));
 }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> Delete(string testId)
        {
            var result = await TestsDao.Delete(this, testId);

            if (result == null)
            {
                return(NotFound());
            }

            return(JsonWithPermissions(result));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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"));
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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 }));
        }
Ejemplo n.º 7
0
        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 }));
        }
Ejemplo n.º 8
0
 public async Task <IHttpActionResult> Create(TestsCreateViewModel model)
 {
     return(JsonWithPermissions(await TestsDao.Create(this, model)));
 }