示例#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)));
 }
示例#3
0
        public Test DeleteTest(int id)
        {
            Test test = Tests.FirstOrDefault(p => p.Id == id);

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

            return(test);
        }
示例#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));
        }
示例#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);
 }
示例#9
0
 public bool DeleteTest(int position, string fileName)
 {
     return(_testRepository.DeleteTest(position, fileName));
 }
示例#10
0
 public void DeleteTest(int id)
 {
     _testRepository.DeleteTest(id);
 }
示例#11
0
 public int DeleteTest(int id)
 {
     return(testRepository.DeleteTest(id));
 }
示例#12
0
 public IHttpActionResult Delete(Guid id)
 {
     testRepository.DeleteTest(id);
     return(Ok());
 }