Exemplo n.º 1
0
        public IResult Add(IFormFile file, UserPhoto photo)
        {
            IResult result = BusinessRules.Run(CheckIfImageLimitExceedded(photo.UserId));

            if (result != null)
            {
                return(result);
            }
            photo.ImagePath = FileHelpers.Add(file);
            _userPhotoDal.Add(photo);
            return(new SuccessResult(Messages.PhotoAdded));
        }
        public IResult Add(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CarImageLimitExceeded(carImage.CarId));

            if (result != null)
            {
                return(result);
            }
            carImage.ImagePath    = FileHelpers.Add(file);
            carImage.CreationDate = DateTime.Now;
            _carImagesDal.Add(carImage);
            return(new SuccessResult(Messages.AddadCarImage));
        }
Exemplo n.º 3
0
        public IResult Add(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckCarImageMaxLimit(carImage));

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

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

            _carImageDal.Add(carImage);
            return(new SuccessResult(Messages.CarImageAdded));
        }
Exemplo n.º 4
0
        public IDataResult <CarImage> Add(IFormFile file, CarImage carImage)
        {
            IResult result = BusinessRules.Run(CheckImageLimitExceeded(carImage.CarId));

            if (result != null)
            {
                return(new ErrorDataResult <CarImage>(result.Message));
            }

            // Refactor edilecek
            string[] path         = FileHelpers.Add(file).Split('\\');
            string   newImagePath = path[path.Length - 2].ToString();

            newImagePath = "/" + newImagePath + "/" + path[path.Length - 1].ToString();


            carImage.ImagePath = newImagePath;
            carImage.Date      = DateTime.Now;
            return(new SuccessDataResult <CarImage>(_carImageDal.Add(carImage)));
        }