public async Task RemoveCondition_RemovesConditionFromDatabase() { //Arrange Guid id = new Guid("58f7b2c7-b8fc-48dc-83ab-862a85c80fc8"); Condition condition = await _conditionService.FindConditionById(id); //Act _conditionService.RemoveCondition(condition); await _unitOfWork.Save(); //Assert Assert.Equal(3, (await _conditionService.FindConditions(resourceParameters)).Count()); Assert.Null(await _conditionService.FindConditionById(id)); }
public async Task <IActionResult> DeleteCondition(Guid id) { var retrievedCondition = await _conditionService.FindConditionById(id); if (retrievedCondition == null) { return(NotFound()); } _conditionService.RemoveCondition(retrievedCondition); if (!await _conditionService.Save()) { throw new Exception($"Deleting condition {id} failed on save."); } return(NoContent()); }