public async Task <IActionResult> DeleteBrand([FromRoute] int id) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!await _brandRepository.BrandExistsAsync(id)) { return(NotFound()); } var wasBrandDeleted = await _brandRepository.DeleteBrandAsync(id); if (wasBrandDeleted) { return(Ok()); } return(NoContent()); } catch (Exception e) { _logger.LogCritical($"DELETE {Route}/{id} - {e.GetType().Name} - {e.Message} - {e.StackTrace}"); return(StatusCode(500, "An error ocurred in server")); } }
public async Task <IActionResult> DeleteBrandAsync(long id) { var removed = await _brandRepository.DeleteBrandAsync(id); if (!removed) { return(NotFound($"Brand with id {id} cannot be found.")); } return(NoContent()); }
public async Task <bool> DeleteBrandAsync(string brandName) { return(await _brandRepository.DeleteBrandAsync(brandName)); }
public async Task DeleteBrandAsync(Guid id) { await _brandRepository.DeleteBrandAsync(id); }