コード例 #1
0
        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"));
            }
        }
コード例 #2
0
        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());
        }
コード例 #3
0
ファイル: BrandService.cs プロジェクト: PhantomCloak/efurni
 public async Task <bool> DeleteBrandAsync(string brandName)
 {
     return(await _brandRepository.DeleteBrandAsync(brandName));
 }
コード例 #4
0
 public async Task DeleteBrandAsync(Guid id)
 {
     await _brandRepository.DeleteBrandAsync(id);
 }