예제 #1
0
        public async Task <bool> DeleteStockByIsinAsync(string isin)
        {
            var existing = await _stockRepository.GetByIsinAsync(isin);

            if (existing == null)
            {
                return(false);
            }

            await _stockRepository.DeleteStockAsync(existing);

            return(true);
        }
예제 #2
0
        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)));
        }
예제 #3
0
        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));
        }