public IResult ProfileImageAdd(IFormFile file, UserImage userImage)
 {
     userImage.ProfileImage  = FileHelper.AddAsync(file);
     userImage.UserImageDate = DateTime.Now;
     _userImageDal.ProfileImageAdd(userImage);
     return(new SuccessResult(Message.PostAdded));
 }
        public IDataResult <string> Add(IFormFile file, UserImage userImage)
        {
            userImage.ImagePath = FileHelper.AddAsync(file);


            string uniqueString = Guid.NewGuid().ToString("N")
                                  + "_" + DateTime.Now.Month + "_"
                                  + DateTime.Now.Day + "_"
                                  + DateTime.Now.Year;

            userImage.UserImageDate = DateTime.Now;
            if (userImage.ImagePath.ToLower().Contains(".png"))
            {
                userImage.ConvertType = "jpeg";
                IDataResult <string> result = Convert(userImage.ImagePath, userImage.ConvertType, uniqueString);
                if (result != null)
                {
                    userImage.ImagePath = "\\Image\\" + uniqueString + "." + userImage.ConvertType;
                    _userImageDal.Add(userImage);
                    return(new SuccessDataResult <string>(result.Data, result.Message));
                }
            }
            else if (userImage.ImagePath.ToLower().Contains(".jpg"))
            {
                userImage.ConvertType = "png";
                IDataResult <string> result = Convert(userImage.ImagePath, userImage.ConvertType, uniqueString);
                if (result != null)
                {
                    userImage.ImagePath = "\\Image\\" + uniqueString + "." + userImage.ConvertType;
                    _userImageDal.Add(userImage);
                    return(new SuccessDataResult <string>(result.Data, result.Message));
                }
            }
            else if (userImage.ImagePath.ToLower().Contains(".jpeg"))
            {
                userImage.ConvertType = "jpg";
                IDataResult <string> result = Convert(userImage.ImagePath, userImage.ConvertType, uniqueString);
                if (result != null)
                {
                    userImage.ImagePath = "\\Image\\" + uniqueString + "." + userImage.ConvertType;
                    _userImageDal.Add(userImage);
                    return(new SuccessDataResult <string>(result.Data, result.Message));
                }
            }
            else
            {
                userImage.ConvertType = "webp";
                IDataResult <string> result = Convert(userImage.ImagePath, userImage.ConvertType, uniqueString);
                if (result != null)
                {
                    userImage.ImagePath = "\\Image\\" + uniqueString + "." + userImage.ConvertType;
                    _userImageDal.Add(userImage);
                    return(new SuccessDataResult <string>(result.Data, result.Message));
                }
            }
            return(new ErrorDataResult <string>(null, Message.NotConvert));
        }
Exemple #3
0
        public IResult Add(CarImage carImage, IFormFile formFile)
        {
            IResult result = BusinessRules.Run(CheckIfImageLimitExceeded(carImage));

            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath = FileHelper.AddAsync(formFile);
            _carImageDal.Add(carImage);
            return(new SuccessResult(Messages.CarImageAdded));
        }
Exemple #4
0
        public IActionResult AddAsync([FromForm(Name = ("Image"))] IFormFile file, [FromForm] CarImage carImage)
        {
            carImage.Date      = DateTime.Now;
            carImage.ImagePath = FileHelper.AddAsync(file);
            var result = _carImageService.Add(carImage);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Exemple #5
0
        public IResult Add(IFormFile formFile, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckImagesLimit(carImage.CarId), CheckValidFileType(formFile));

            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath    = FileHelper.AddAsync(formFile);
            carImage.CarImageDate = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
        public IResult Add(IFormFile file, CarImage carImage)
        {
            var result = BusinessRules.Run(CheckIfImagesCount(carImage.CarID));

            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath = FileHelper.AddAsync(file);
            carImage.ImageDate = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
        public IResult Add(IFormFile file, CarImage entity)
        {
            var result = BusinessRules.Run(CheckIfCarImageLimitExceded(entity.CarId));

            if (result != null)
            {
                return(result);
            }
            entity.ImagePath = FileHelper.AddAsync(file);
            entity.Date      = DateTime.Now;
            _carImageDal.Add(entity);
            return(new SuccessResult("Görsel Eklendi"));
        }
        public IResult Add(CarImage carImage, IFormFile file)
        {
            IResult result = BusinessRules.Run(CheckNumberOfImages(carImage.CarId));

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

            carImage.ImagePath = FileHelper.AddAsync(file);
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
        public IResult Add(IFormFile file, ImagesCar images)
        {
            IResult result = BusinessRules.Run(CheckIfCarImagesLimitExceed(images.CarId));

            if (result != null)
            {
                return(result);
            }
            images.ImagePath = FileHelper.AddAsync(file);
            images.ImageDate = DateTime.Now;
            _imagesCarDal.Add(images);
            return(new SuccessResult());
        }
        public IResult Add(IFormFile formFile, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckCarImageLımıt(carImage.CarId));

            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath = FileHelper.AddAsync(formFile); //burda ımagepathimize file helper yardımıyla dosyayı ekledik.
            carImage.Date      = DateTime.Now;                  //tarihimize şuan ki saatten aldık.
            _ICarImagedal.Add(carImage);
            return(new SuccessResult(Messages.AddedCarImages));
        }
        public IResult Add(IFormFile formFile, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckIfCarImagesLimitExceded(carImage.CarId));

            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath = FileHelper.AddAsync(formFile);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult(Messages.CarImagesAdded));
        }
Exemple #12
0
        public IResult Add(IFormFile file, CarImage carImage)
        {
            var     fileUpload = FileHelper.AddAsync(file);
            IResult result     = BusinessRules.Run(CheckImageCount(carImage.CarId), fileUpload);

            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath = fileUpload.Data;
            carImage.Date      = DateTime.Now;
            _carImage.Add(carImage);
            return(new SuccessResult(Messages.CarImageAdded));
        }
Exemple #13
0
        public IResult Add(IFormFile file, Image image)
        {
            IResult result = BusinessRules.Run(CheckCountOfImage(image.CarId));

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

            image.ImagePath = FileHelper.AddAsync(file);
            image.Date      = DateTime.Now;
            _imageDal.Add(image);
            return(new SuccessResult(Messages.ImageAdded));
        }
Exemple #14
0
        public IResult Add(CarImage carImage, IFormFile file)
        {
            IResult result = BusinessRules.Run(CheckIfImageLimitExceeded());

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

            carImage.ImagePath = FileHelper.AddAsync(file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
        //[SecuredOperation("admin,member")]
        public IResult Add(IFormFile formFile, CarImage carImage)
        {
            //Fotoğraf sayısını kontrol et
            var countResult = BusinessRules.Run(CheckImageLimit(carImage.CarId));

            if (countResult != null)
            {
                return(countResult);
            }
            //Resmi dosyaya ekle ardından yolunu veritabanına ekle
            carImage.ImagePath  = FileHelper.AddAsync(formFile);
            carImage.UploadDate = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult(Messages.ImagesAdded));
        }
        //[ValidationAspect(typeof(CarImageValidator))]
        public IResult Add(IFormFile file, CarImage entity)
        {
            var result = BusinessRules.Run(CheckNumOfCarImages(entity.CarId));

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

            entity.ImagePath = FileHelper.AddAsync(file);
            entity.ImageDate = DateTime.Now;
            _carImageDal.Add(entity);

            return(new SuccessResult(Messages.Added));
        }
        public IResult Add(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckIfImageLimitExceeded(carImage.CarId));

            if (result != null)
            {
                return(result);
            }
            string Path = FileHelper.AddAsync(file);

            carImage.ImagePath = Path.Split('\\').Last();
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
        //[CacheRemoveAspect("ICarImageService.Get")]
        public IResult Add(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(
                CheckUploadedImagesLimit(carImage.CarId)
                );

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

            carImage.ImagePath = FileHelper.AddAsync(file);
            _imageDal.Add(carImage);
            return(new SuccessResult());
        }
        public IResult Update(IFormFile file, CarImage carImage)
        {
            var result = BusinessRules.Run(CheckCarImageCount(carImage));

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

            carImage.ImagePath = FileHelper.AddAsync(file);
            carImage.Date      = DateTime.Now;

            _carImageDal.Update(carImage);
            return(new SuccessResult(Messages.Updated));
        }
Exemple #20
0
        public IResult Add(IFormFile file, CarImages carImages)
        {
            IResult result = BusinessRules.Run(
                CheckIfImageLimit(carImages.CarId)
                );

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

            carImages.ImagePath = FileHelper.AddAsync(file);
            carImages.Date      = DateTime.Now;
            _carImagesDal.Add(carImages);
            return(new SuccessResult());
        }
        public IResult Add(IFormFile file, CarImage carImage)
        {
            //IResult result = BusinessRules.Run(
            //    CheckIfImageLimit(carImage.CarId)
            //    );

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

            carImage.ImagePath = FileHelper.AddAsync(file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
Exemple #22
0
        public IResult Add(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckCarImageLimit(carImage));

            //business codes
            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath = FileHelper.AddAsync(file);
            carImage.ImageDate = DateTime.Now;


            _carImageDal.Add(carImage);
            return(new SuccessResult(Messages.CarImageAdded));


            //   return new ErrorResult();
        }
        public async Task <IResult> AddAsync(CurriculumVitae cv, IFormFile file)
        {
            var ruleResult = BusinessRules.Run(ExtensionCheck(file));

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

            var pathCreator = PathCreator(file);

            cv.FilePath    = pathCreator.fileName;
            cv.CreatedDate = DateTime.Now;
            cv.UpdatedDate = DateTime.Now;
            cv.Status      = true;
            await _curriculumVitaeDal.AddAsync(cv);

            await FileHelper.AddAsync(file, pathCreator.path);

            return(new SuccessResult(Messages.CurriculumVitae.AddSuccess));
        }
        public IResult Add(IFormFile formFile, CarImage carImage)
        {
            IResult result = BusinessRules.Run(
                CheckIfImageLimit(carImage.CarId),
                CheckIfimageGetExtension(formFile)
                );

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

            CarImage cImage = new CarImage()
            {
                CarId = carImage.CarId
            };

            cImage.Date      = DateTime.Now;
            cImage.ImagePath = FileHelper.AddAsync(formFile);
            _carImageDal.Add(cImage);

            return(new SuccessResult());
        }