public async Task <bool> DeleteStockByIsinAsync(string isin) { var existing = await _stockRepository.GetByIsinAsync(isin); if (existing == null) { return(false); } await _stockRepository.DeleteStockAsync(existing); return(true); }
public async Task <IActionResult> DeleteStock(DeleteStockViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var deletedStock = await _stockRepository.DeleteStockAsync(model.StockId); if (deletedStock == null) { return(NotFound()); } return(RedirectToAction(nameof(Stocks))); }
public async Task <bool> RemoveCarAsync(int carId, int dealerId) { //check if car exists. var car = await _carRepository.GetCarByIdAsync(carId); if (car == null) { return(true); } //delete the stock from the dealer if car exists var stock = await _stockRepository.GetStockAsync(carId, dealerId); if (stock == null) { return(true); } return(await _stockRepository.DeleteStockAsync(stock)); }