Example #1
0
        public IResult Delete(CarImage entity)
        {
            var     delete = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\wwwwroot\\Images")) + _carImageDal.Get(c => c.Id == entity.Id).ImagePath;
            IResult result = BussinessRules.Run(FileHelper.DeleteAsync(delete));

            _carImageDal.Delete(entity);
            return(new SuccessResult(Messages.Deleted));
        }
Example #2
0
        public IDataResult <List <CarImage> > GetCarImages(int id)
        {
            IResult result = BussinessRules.Run(CheckImageNull(id));

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

            return(new SuccessDataResult <List <CarImage> >(CheckImageNull(id).Data));
        }
Example #3
0
        [ValidationAspect(typeof(ProductValidator))] // Attribute lara typeof ile tipi atarız. Tipleri Typeof İle atarız. Dikkat instance değil sadece tipi yolluyoruz.
        public IResult Add(Product product)
        {
            IResult result = BussinessRules.Run(CheckIfProductCountOfCategoryCorrect(product.CategoryId), CheckIfProductNameExists(product.ProductName), CheckIfCategoryLimitExceeded());

            if (result != null)
            {
                return(result);
            }
            _productDal.Add(product);
            return(new SuccessResult(Messages.ProductAdded));
        }
Example #4
0
        public IResult Update(Brand entity)
        {
            IResult result = BussinessRules.Run(CheckBrandId(entity.Id));

            if (result != null)
            {
                return(new ErrorResult(result.Message));
            }
            _brandDal.Update(entity);
            return(new SuccessResult());
        }
Example #5
0
        //[ValidationAspect(typeof(CarImageValidator))]
        public IResult Add(IFormFile file, CarImage entity)
        {
            IResult result = BussinessRules.Run(CheckCarImages(entity.CarId), CheckCarId(entity.CarId), CheckIfImageExtension(file.FileName));

            if (result != null)
            {
                return(result);
            }
            entity.ImagePath = FileHelper.AddAsnyc(file);
            entity.Date      = DateTime.Today;
            _carImageDal.Add(entity);
            return(new SuccessResult(Messages.Added));
        }
Example #6
0
        public IResult Add(CarImage carImage)
        {
            var result = BussinessRules.Run(CheckCarImageLimitExceded(carImage.CarId));

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

            TakeImagePath(carImage);

            _carImageDal.Add(carImage);
            return(new SuccessResult(Messages.Added));
        }
Example #7
0
        public IResult Add(IFormFile file, CarImage carImage)
        {
            IResult result = BussinessRules.Run(CheckIfCarImageLimitExceeded(carImage.CarId));

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

            carImage.ImagePath = FileHelper.Add(file);
            carImage.DateTime  = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult());
        }
Example #8
0
        public IResult Update(CarImage carImage)
        {
            var result = BussinessRules.Run(CheckCarImageLimitExceded(carImage.CarId));

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

            string newPath = TakeImagePath(carImage);

            carImage.ImagePath = newPath;
            _carImageDal.Update(carImage);
            return(new SuccessResult(Messages.Updated));
        }
Example #9
0
        public IDataResult <List <CarImage> > GetImagesByCarId(int id)
        {
            var result = BussinessRules.Run(CheckCarImageCount(id));

            if (result != null)
            {
                return(new ErrorDataResult <List <CarImage> >(new List <CarImage> {
                    new CarImage {
                        ImagePath = "C:\\Users\\DDogan\\Desktop\\EnginHoca\\Proje\\Images\\CarImages\\logo.jpg"
                    }
                }));
            }

            return(new SuccessDataResult <List <CarImage> >(_carImageDal.GetAll(c => c.CarId == id)));
        }
Example #10
0
        public IResult Add(Product product)
        {
            IResult result = BussinessRules.Run(CheckIfProductCountOfCategoryCorrect(product.CategoryId),
                                                CheckIfProductNameExists(product.ProductName), CheckIfCategoryLimitExceded());

            if (result != null)
            {
                return(result);
            }
            _productDal.Add(product);

            return(new SuccessResult(Messages.ProductAdded));

            //Validation
            //doğrulama eklemeye çalıştığımız nesneyi iş kurallarına dahil etmek için bu nesnenin yapısal olarak doğru olup olmadığını kontrol eder
        }
Example #11
0
        public IDataResult <CarImage> Get(int id)
        {
            IResult result = BussinessRules.Run(CheckImageNull(id));

            return(new SuccessDataResult <CarImage>(_carImageDal.Get(p => p.Id == id)));
        }