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 Add(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckImageLimitExceeded(carImage.CarId));

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

            carImage.ImagePath = CarImageFileHelper.Add(file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
        public IResult Add(CarImage carImage, IFormFile file)
        {
            IResult result = BusinessRules.Run(CheckMaxCarImage(carImage.CarId));

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

            carImage.ImagePath = CarImageFileHelper.Add(file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult(Messages.CarImageAdded));
        }
Example #4
0
        public IResult Delete(CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckIfImageExsits(carImage.Id));

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

            string path = GetByCarImageId(carImage.Id).Data.ImagePath;

            CarImageFileHelper.Delete(path);
            _carImageDal.Delete(carImage);
            return(new SuccessResult());
        }
        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());
        }
        // [ValidationAspect(typeof(CarImageValidator))]
        public IResult Add(CarImage carImage, IFormFile file)
        {
            IResult result = BusinessRules.Run(CheckIfImageLimitExpired(carImage.CarId),
                                               CheckIfImageExtensionValid(file));

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

            carImage.ImagePath = CarImageFileHelper.Add(file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);

            return(new SuccessResult());
        }
Example #7
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());
        }
 public IResult Delete(CarImage carImage)
 {
     CarImageFileHelper.Delete(carImage.ImagePath);
     _carImageDal.Delete(carImage);
     return(new SuccessResult());
 }