public async Task Delete_WhenCalled_ReturnsTrue() { // Arrange var productCategoryId = _fixture.Items.FirstOrDefault().Id; _mockRepository.Setup(r => r.DeleteAsync(productCategoryId)).ReturnsAsync(true); // Act var productCategoryResult = await _sut.DeleteAsync(productCategoryId); // Assert productCategoryResult.Should().Be(true); _mockRepository.Verify(r => r.DeleteAsync(It.IsAny <int>()), Times.Once); }
public async Task <IActionResult> Delete(int id) { if (id == 0) { return(new BadRequestResult()); } else { await _productCategoryService.DeleteAsync(id); _productCategoryService.Save(); return(new OkObjectResult(id)); } }
public virtual async Task <JsonResult> Delete(int id) { var delete = await _productCatSrv.DeleteAsync(id); if (!delete.IsSuccessful) { return(Json(delete)); } return(Json(new { IsSuccessful = true, Result = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_List", _productCatSrv.GetAll(new ProductCategorySearchFilter())) })); }
public async Task <IActionResult> Delete(int id) { _logger.LogInformation("Entered in [DELETE] /productcategories endpoint with id {}", id); IActionResult result; if (await _productCategoryService.DeleteAsync(id)) { result = NoContent(); } else { result = BadRequest(); } return(result); }
public async Task <IActionResult> Delete(int id) { if (!ModelState.IsValid) { return(RedirectToErrorPage()); } var isActived = await _productCategoryService.DeleteAsync(id); if (!isActived) { return(RedirectToErrorPage()); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Delete(long id) { await _categoryService.DeleteAsync(id); return(Ok()); }
public async Task <IActionResult> OnPostDeleteAsync(params long[] id) { await _service.DeleteAsync(id); return(JsonData(true)); }
public async Task <IActionResult> deleteProductCategory(Guid id) { var response = await _productCategoryService.DeleteAsync(id); return(Ok(response)); }