//[ValidationAspect(typeof(CarImagesOperationDtoValidator))] public IResult Update(CarImagesOperationDto carImagesOperationDto) { foreach (var file in carImagesOperationDto.Images) { var result = BusinessRules.Run( CheckIfCarImagesId(carImagesOperationDto.Id), CheckCarImageCount(carImagesOperationDto.CarId), CheckIfCarId(carImagesOperationDto.CarId) ); if (result != null) { return(result); } FileProcessHelper.Delete(_carImageDal.Get(p => p.ImageID == carImagesOperationDto.Id).ImagePath); _carImageDal.Update(new CarImage { ImageID = carImagesOperationDto.Id, CarID = carImagesOperationDto.CarId, ImagePath = FileProcessHelper.Upload(DefaultNameOrPath.ImageDirectory, file).Data }); } return(new SuccessResult(Messages.EditCarImageMessage)); }
public IResult Add(CarImagesOperationDto carImagesOperationDto) { var result = BusinessRules.Run( CheckCarImageCount(carImagesOperationDto.CarId)); if (result != null) { return(result); } foreach (var file in carImagesOperationDto.Images) { _carImageDal.Add(new CarImage { CarId = carImagesOperationDto.CarId, ImagePath = FileProcessHelper.Upload(DefaultNameOrPath.ImageDirectory, file).Data }); } return(new SuccessResult()); }