public void WhenMediaIsDeleted_AndItBelongsToTheUser_ThenItIsDeleted() { int userId = 1; _mediaRepository.Setup(m => m.GetMedia(It.IsAny <int>())).Returns(new Media { UserId = userId }); mediaService.DeleteMedia(It.IsAny <int>(), userId); Assert.True(true, "No exceptions thrown"); }
public void DeleteExistingBookShouldBeTrue() { var(id, name, category) = FakeMediaFactory.GetTotoBookWithId(); var(result, errorOption) = _mediaService.DeleteMedia(id); result .Should() .BeTrue(); errorOption .HasValue .Should() .BeFalse(); }
public void DeleteExistingMedia_ShouldBeTrue() { var id = FakeMediaFactory.GetTotoIdMedia(); var(result, errorOption) = _mediaService.DeleteMedia(id); result .Should() .BeTrue(); errorOption .HasValue .Should() .BeFalse(); }
public async Task <IActionResult> Delete(Guid id) { try { var folderId = await _service.DeleteMedia(id); var result = await _service.GetList(folderId); result.Status = new StatusMessage { Type = StatusMessage.Success, Body = $"The media file was successfully deleted" }; return(Ok(result)); } catch (ValidationException e) { var result = new MediaListModel(); result.Status = new StatusMessage { Type = StatusMessage.Error, Body = e.Message }; return(BadRequest(result)); } }
public async Task <IActionResult> Delete([FromBody] IEnumerable <Guid> items) { try { foreach (var id in items) { await _service.DeleteMedia(id); } return(Ok(new StatusMessage { Type = StatusMessage.Success, Body = _localizer.Media[$"The media file{(items.Count() > 1 ? "s" : "")} was successfully deleted"] })); } catch (ValidationException e) { return(BadRequest(new StatusMessage { Type = StatusMessage.Error, Body = e.Message })); } }