public IResult Update(IFormFile formFile, CarImages entity) { var result = BusinessRules.Run(CheckImagesLimited(entity.CarId)); if (result != null) { return result; } entity.ImagePath = FileHelper.Update(_carImagesDal.GetById(p => p.Id == entity.Id).ImagePath, formFile); entity.Date = DateTime.Now; _carImagesDal.Update(entity); return new SuccessResult(); }
public IResult Delete(CarImages carImages) { var oldpath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\wwwroot")) + _carImagesDal.GetById(p => p.Id == carImages.Id).ImagePath; IResult result = BusinessRules.Run( FileHelper.DeleteAsync(oldpath)); if (result != null) { return(result); } _carImagesDal.Delete(carImages); return(new SuccessResult()); }