Example #1
0
 public void DeleteTest(int testId)
 {
     using (Repo = new TestRepository())
     {
         try
         {
             Repo.DeleteTest(testId);
         }
         catch (NullReferenceException ex)
         {
             throw;
         }
         catch (NotSupportedException ex)
         {
         }
         catch (ObjectDisposedException ex)
         {
         }
         catch (InvalidOperationException ex)
         {
         }
         catch (Exception ex)
         {
         }
     }
 }
 public IActionResult DeleteTest(int id)
 {
     if (id == 0)
     {
         return(BadRequest("Please provide id"));
     }
     return(Ok(_iTest.DeleteTest(id)));
 }
Example #3
0
        public Test DeleteTest(int id)
        {
            Test test = Tests.FirstOrDefault(p => p.Id == id);

            if (test != null)
            {
                repository.DeleteTest(test);
            }

            return(test);
        }
Example #4
0
        public IActionResult DeleteTest(Guid testId)
        {
            var deleteTest = testRepository.FindTest(testId);

            if (deleteTest == null)
            {
                return(NotFound());
            }
            testRepository.DeleteTest(deleteTest);
            return(RedirectToAction("dashboard", "examiner"));
        }
        public async Task <IActionResult> DeleteTest([FromRoute] int testId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (!await _testRepository.IsTestExistAsync(testId))
            {
                return(NotFound());
            }

            await _testRepository.DeleteTest(testId);

            return(Ok(testId));
        }
Example #6
0
 public ActionResult Edit(int?ID, int?Delete)
 {
     if (Delete == null)
     {
         TestPreview test = TestRepository.Tests.First(x => x.Id == ID);
         return(View(test));
     }
     else
     {
         TestPreview test        = TestRepository.Tests.First(x => x.Id == ID);
         TestPreview deletedTest = TestRepository.DeleteTest(test.Id);
         if (deletedTest != null)
         {
             TempData["message"] = string.Format("Тест \"{0}\" был удален",
                                                 deletedTest.Theme);
         }
         return(RedirectToAction("Index"));
     }
 }
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                if ((await _repository.GetTest(id)).UserId != User.FindFirst(ClaimTypes.NameIdentifier)?.Value &&
                    !User.IsInRole("Admin"))
                {
                    return(new UnauthorizedResult());
                }

                if (!await _repository.DeleteTest(id))
                {
                    throw new Exception($"Error during deleting test ith id: {id}");
                }
                await _hubContext.Clients.All.TestRemoved(id);

                return(new NoContentResult());
            }
            catch (Exception e)
            {
                return(new StatusCodeResult(500));
            }
        }
 public void DeleteTest(int testId)
 {
     testRepository.DeleteTest(testId);
 }
Example #9
0
 public bool DeleteTest(int position, string fileName)
 {
     return(_testRepository.DeleteTest(position, fileName));
 }
Example #10
0
 public void DeleteTest(int id)
 {
     _testRepository.DeleteTest(id);
 }
Example #11
0
 public int DeleteTest(int id)
 {
     return(testRepository.DeleteTest(id));
 }
Example #12
0
 public IHttpActionResult Delete(Guid id)
 {
     testRepository.DeleteTest(id);
     return(Ok());
 }