[Route("{id:int}"), HttpDelete] // DELETE: api/video/5 public HttpResponseMessage Delete(int id) { SuccessResponse resp = new SuccessResponse(); VideoService.Delete(id); return(Request.CreateResponse(HttpStatusCode.OK, resp)); }
public IActionResult Delete(string id) { var Video = _VideoService.Get(id); if (Video == null) { return(NotFound()); } _VideoService.Delete(Video.Id); return(NoContent()); }
public IActionResult Delete(int id) { if (!ModelState.IsValid) { return(new BadRequestObjectResult(ModelState)); } else { _videoService.Delete(id); _videoService.Save(); return(new OkObjectResult(id)); } }
public ActionResult Delete(int id, FormCollection collection) { try { gs.Delete(gs.GetByIdVideo(id)); var idg = gs.GetByIdVideo(id).galerie_id; gs.Commit(); return(RedirectToAction("Index", "Galerie")); } catch { return(View()); } }
public async void Delete_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <IVideoService, IVideoRepository>(); var model = new ApiVideoServerRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new VideoService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.VideoModelValidatorMock.Object, mock.DALMapperMockFactory.DALVideoMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.VideoModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <VideoDeletedNotification>(), It.IsAny <CancellationToken>())); }
public async void Delete_ErrorsOccurred_ShouldReturnErrorResponse() { var mock = new ServiceMockFacade <IVideoService, IVideoRepository>(); var model = new ApiVideoServerRequestModel(); var validatorMock = new Mock <IApiVideoServerRequestModelValidator>(); validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>() { new ValidationFailure("text", "test") }))); var service = new VideoService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, validatorMock.Object, mock.DALMapperMockFactory.DALVideoMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeFalse(); validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <VideoDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never()); }
private void MethodDeleteThrowsExceptionWhenInvalid() { _repository.Setup(repo => repo.Delete(_video1)).Throws(new Exception()); Assert.Throws <Exception>(() => _service.Delete(_videoDto1)); }
public StatusResponse Delete(Guid guid) => _videos.Delete(guid);