public IHttpActionResult Delete(int id) { using (_instructorService) { _instructorService.Delete(id); } return(Ok()); }
// GET: Instructors/Delete/5 public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } await _instructorService.Delete(id.Value); return(RedirectToAction("Index")); }
public void DeleteInstructor_WhereInstructorExists_ReturnsOkResponse([Values(1, 2, 3)] int idOfInstructorToDelete) { //Arrange Mock.Arrange(() => _instructorService.Delete(idOfInstructorToDelete)).OccursOnce(); var instructorController = new InstructorController(_instructorService); ////Act var actual = instructorController.Delete(idOfInstructorToDelete) as OkResult; //Assert Mock.Assert(_instructorService); Assert.That(actual, Is.TypeOf <OkResult>()); }
public async Task <object> DeleteInstructor(int id) { try { if (await CheckPermissionToDeleteInstructor(id)) { Response response = await _service.Delete(id); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <IActionResult> DeleteConfirmed(int id) { try { await instructorService.Delete(id); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { ViewBag.Message = ex.Message; ViewBag.Type = "danger"; return(View("Delete")); } }
public async Task <IActionResult> DeleteConfirmed(int id) { var instructor = await _instructorService.GetById(id); try { await _instructorService.Delete(id); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { ViewBag.Message = ex.Message; ViewBag.Type = "danger"; var instructorDTO = _mapper.Map <InstructorDTO>(instructor); return(View("Delete", instructorDTO)); } }