public IActionResult Delete([FromForm] CarImage entity) { var result = _carImageManager.Delete(entity); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public IActionResult Delete([FromForm(Name = ("Id"))] int Id) { var carImage = _carImageManager.Get(Id).Data; var result = _carImageManager.Delete(carImage); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public IActionResult Delete(CarImage carImage) { var result = _carImageManager.Delete(carImage); if (result.IsSuccessful) { return(Ok(result)); } return(BadRequest(result)); }
public IActionResult Delete([FromForm] CarImage entity) { var result = _carImageManager.Delete(entity); if (result.Success) { System.IO.File.SetAttributes(_environment.WebRootPath + entity.ImagePath, FileAttributes.Normal); System.IO.File.Delete(_environment.WebRootPath + entity.ImagePath); return(Ok(result.Message)); } return(BadRequest(result.Message)); }
private void DeleteImages(CarItem dbItem, IEnumerable <int> ids) { var dbImagesArrayForDelete = dbItem.CarImages.Where(x => ids.Contains(x.Id)).ToList(); foreach (var item in dbImagesArrayForDelete) { //remove from dbitem dbItem.CarImages.Remove(item); //remove from database _carImageManager.Delete(item); } }