public void DeleteImage(int id, int autoId, int userId) { var auto = _autoRepo.GetById(autoId); if (auto.UserId != userId) { throw new Exception("You don't own this car"); } foreach (var image in auto.Images.Where(image => image.Id == id)) { _autoRepo.DeleteImage(id); } }