public IResult Update(CarImage carImage, IFormFile file)
 {
     carImage.ImagePath = CarImageFileHelper.Update(_carImageDal.Get(c => c.Id == carImage.Id).ImagePath, file);
     carImage.Date      = DateTime.Now;
     _carImageDal.Update(carImage);
     return(new SuccessResult(Messages.CarImageUpdated));
 }
        public IResult Update(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckImageLimitExceeded(carImage.CarId));

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

            var oldPath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\wwwroot")) + _carImageDal.Get(p => p.Id == carImage.Id).ImagePath;

            carImage.ImagePath = CarImageFileHelper.Update(oldPath, file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Update(carImage);
            return(new SuccessResult());
        }
Exemplo n.º 3
0
        public IResult Update(CarImage carImage, IFormFile file)
        {
            IResult result = BusinessRules.Run(
                CheckIfCarImageLimitExceded(carImage.CarId),
                CheckIfImageExsits(carImage.Id),
                CheckIfImageExtensionValid(file));

            if (result != null)
            {
                return(result);
            }
            carImage.DateTime = DateTime.Now;
            string OldPath = GetByCarImageId(carImage.Id).Data.ImagePath;

            carImage.ImagePath = CarImageFileHelper.Update(file, OldPath);
            _carImageDal.Update(carImage);
            return(new SuccessResult());
        }