Esempio n. 1
0
        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.Id == carImagesOperationDto.Id).ImagePath);
                _carImageDal.Update(new CarImages
                {
                    Id        = carImagesOperationDto.Id,
                    CarId     = carImagesOperationDto.CarId,
                    ImagePath = FileProcessHelper.Upload(DefaultNameOrPath.ImageDirectory, file).Data
                });
            }

            return(new SuccessResult(Messages.EditCarImageMessage));
        }
Esempio n. 2
0
 public IResult Update(IFormFile file, CarImage carImage)
 {
     carImage.ImagePath = FileHelper.Update(_carImageDal.Get(c => c.Id == carImage.Id).ImagePath, file);
     carImage.ImageDate = DateTime.Now;
     _carImageDal.Update(carImage);
     return(new SuccessResult());
 }
Esempio n. 3
0
        public IResult Update(IFormFile file, CarImages carImages)
        {
            var oldpath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\wwwroot")) + _carImagesDal.GetById(p => p.Id == carImages.Id).ImagePath;

            carImages.ImagePath = FileHelper.UpdateAsync(oldpath, file);
            carImages.Date      = DateTime.Now;
            _carImagesDal.Update(carImages);
            return(new SuccessResult());
        }
        public IResult Update(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckImageLimitExceeded(carImage.CarId));

            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath = FileHelper.Update(_carImageDal.Get(p => p.Id == carImage.Id).ImagePath, file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Update(carImage);
            return(new SuccessResult());
        }
Esempio n. 5
0
        public IResult Update(IFormFile formFile, CarImages entity)
        {

            var result = BusinessRules.Run(CheckImagesLimited(entity.CarId));
            if (result != null)
            {
                return result;
            }
            entity.ImagePath = FileHelper.Update(_carImagesDal.GetById(p => p.Id == entity.Id).ImagePath, formFile);
            entity.Date = DateTime.Now;
            _carImagesDal.Update(entity);
            return new SuccessResult();
        }
        private IResult UpdateMetod(Image image, CarImages carImage)
        {
            var isImage = _carImageDal.Get(c => c.Id == carImage.Id);

            if (isImage == null)
            {
                return(new ErrorResult("Image not found"));
            }

            var imagePathh = "wwwroot" + isImage.ImagePath;

            if (File.Exists(imagePathh.Replace("/", "\\")))
            {
                File.Delete(imagePathh.Replace("/", "\\"));
            }

            var    path             = "\\Images\\";
            var    currentDirectory = Environment.CurrentDirectory + "\\wwwroot";
            string randomName       = null;
            string type             = null;

            if (image.Files != null && image.Files.Length > 0)
            {
                randomName = Guid.NewGuid().ToString();
                type       = Path.GetExtension(image.Files.FileName);

                if (!Directory.Exists(currentDirectory + path))
                {
                    Directory.CreateDirectory(currentDirectory + path);
                }

                if (type != ".jpeg" && type != ".png" && type != ".jpg")
                {
                    return(new ErrorResult("Wrong file type."));
                }

                using (FileStream fs = System.IO.File.Create(currentDirectory + path + randomName + type))
                {
                    image.Files.CopyTo(fs);
                    fs.Flush();
                    carImage.ImagePath = (path + randomName + type).Replace("\\", "/");
                    carImage.Date      = isImage.Date;
                }

                _carImageDal.Update(carImage);
                return(new SuccessResult("Car image updated"));
            }
            return(new ErrorResult("File doesn't exists"));
        }
Esempio n. 7
0
        public IResult Update(IFormFile image, CarImage carImage)
        {
            var isImage = _carImagesDal.Get(c => c.CarImageId == carImage.CarImageId);

            if (isImage == null)
            {
                return(new ErrorResult("Image not found"));
            }

            var updatedFile = FileHelper.Update(image, isImage.ImagePath);

            if (!updatedFile.Success)
            {
                return(new ErrorResult(updatedFile.Message));
            }
            carImage.ImagePath = updatedFile.Message;
            _carImagesDal.Update(carImage);
            return(new SuccessResult("Car image updated"));
        }
Esempio n. 8
0
        public IResult Update(IFormFile image, CarImages carImage)
        {
            var isImage = _carImageDal.Get(c => c.Id == carImage.Id);

            if (isImage == null)
            {
                return(new ErrorResult(Messages.NotFoundImage));
            }

            var updatedFile = FileHelper.Update(image, isImage.ImagePath);

            if (!updatedFile.Success)
            {
                return(new ErrorResult(updatedFile.Message));
            }
            carImage.ImagePath = updatedFile.Message;
            _carImageDal.Update(carImage);
            return(new SuccessResult(Messages.UpdatedImage));
        }
Esempio n. 9
0
        public IResult Update(CarImages carImages, IFormFile file)
        {
            IResult result = BusinessRules.Run(
                CheckIfImageLimitExpired(carImages.CarId),
                CheckIfImageExtensionValid(file),
                CheckIfImageExists(carImages.Id)
                );

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

            CarImages oldCarImage = GetById(carImages.Id).Data;

            carImages.ImagePath = FileHelper.Update(file, oldCarImage.ImagePath);
            carImages.Date      = DateTime.Now;
            carImages.CarId     = oldCarImage.CarId;
            _carImageDal.Update(carImages);
            return(new SuccessResult());
        }
Esempio n. 10
0
        public IResult UpdateCarImage(UpdateCarImageDto updateCarImageDto)
        {
            var result = BusinessRules.Run(
                CheckIfImageFile(updateCarImageDto.CarImage)

                );

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

            var imageUploadResult = _fileHelper.WriteFile(Consts.ImageUploadUrl, updateCarImageDto.CarImage);

            var entityToUpdate = _carImagesDal.Get(ci => ci.CarImageId == updateCarImageDto.CarImageId);

            entityToUpdate.ImagePath = imageUploadResult[0];

            _carImagesDal.Update(entityToUpdate);

            return(new SuccessResult(Messages.CarImageUpdated));
        }
 public IResult Update(CarImages images)
 {
     _carImageDal.Update(images);
     return(new SuccessResult(Messages.Updated));
 }
 public IResult Update(CarImage carImages)
 {
     _carImagesDal.Update(carImages);
     return(new SuccessResult("Araba başarıyla güncellendi."));
 }
 public IResult Update(CarImage entity)
 {
     entity.Date = DateTime.Now;
     _carImageDal.Update(entity);
     return(new SuccessResult(Messages.EntityUpdated));
 }
 public IResult Update(CarImage carImages)
 {
     _carImagesDal.Update(carImages);
     return(new SuccessResult(Messages.CarImagesUpdated));
 }
Esempio n. 15
0
 public IResult Update(CarImages carImages)
 {
     _carImagesDal.Update(carImages);
     return(new SuccessResult("resim güncellendi"));
 }