Ejemplo n.º 1
0
        public IResult Update(IFormFile file, CarImage carImage)
        {
            var result = BusinessRules.Run(CheckIfFileIsEmpty(file), CheckIfExtensionsAreAllowed(file));

            if (result != null)
            {
                return(result);
            }

            var updatedImage = _carImageDal.Get(c => c.Id == carImage.Id);

            updatedImage.CarId = carImage.CarId;
            var existingPath = ExistingPath(updatedImage.ImagePath);

            updatedImage.ImagePath = FileManagerHelper.Update(file, existingPath);
            updatedImage.Date      = DateTime.Now;

            _carImageDal.Update(updatedImage);
            return(new SuccessResult(Messages.Success));
        }