Ejemplo n.º 1
0
        public async Task <IResult> DeleteAsync(CarImageDeleteDto carImageDeleteDto)
        {
            var carImageResult = await this.GetByIdAsync(carImageDeleteDto.Id);

            if (!carImageResult.Success)
            {
                return(new ErrorResult(carImageResult.Message));
            }

            var fileRemoveResult = FileHelper.FileRemove(carImageResult.Data.ImagePath);

            if (!fileRemoveResult.Success)
            {
                return(new ErrorResult(Messages.RegisteredCarImageNotDeleted));
            }

            bool deleteResult = _carImageDal.Delete(carImageResult.Data);

            if (!deleteResult)
            {
                return(new ErrorResult(Messages.CarImageNotDeleted));
            }

            return(new SuccessResult(Messages.CarImageDeleted));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DeleteAsync(CarImageDeleteDto carImageDeleteDto)
        {
            var deleteResult = await _carImageService.DeleteAsync(carImageDeleteDto);

            if (!deleteResult.Success)
            {
                return(BadRequest(deleteResult));
            }

            return(Ok(deleteResult));
        }