Пример #1
0
        public IResult Add(IFormFile file, Images carImage)
        {
            var imageCount = _carImageDAL.GetAll(c => c.CarId == carImage.CarId).Count;

            if (imageCount >= 5)
            {
                return(new ErrorResult("One car must have 5 or less images"));
            }

            var imageResult = FileHelper.Upload(file);

            if (!imageResult.Success)
            {
                return(new ErrorResult(imageResult.Message));
            }
            carImage.ImagePath = imageResult.Message;
            _carImageDAL.Add(carImage);
            return(new SuccessResult("Car image added"));
        }
Пример #2
0
        public IResult Add(IFormFile file, Images filmImage)
        {
            var imageCount = _filmImagesDal.GetAll(f => f.FilmId == filmImage.FilmId).Count;

            if (imageCount >= 5)
            {
                return(new ErrorResult("One film must have 5 or less images"));
            }

            var imageResult = FileHelper.Upload(file);

            if (!imageResult.Success)
            {
                return(new ErrorResult(imageResult.Message));
            }
            filmImage.ImagePath = imageResult.Message;
            _filmImagesDal.Add(filmImage);
            return(new SuccessResult("film image added"));
        }
Пример #3
0
 public IDataResult <List <Images> > GetAll()
 {
     return(new SuccessDataResult <List <Images> >(_imagesDal.GetAll()));
 }