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)); }
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)); }
[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)); }
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()); }
//[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)); }
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)); }
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()); }
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)); }
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))); }
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 }
public IDataResult <CarImage> Get(int id) { IResult result = BussinessRules.Run(CheckImageNull(id)); return(new SuccessDataResult <CarImage>(_carImageDal.Get(p => p.Id == id))); }