public IActionResult DeleteSupermarket(int supermarketId) { // get supermarket for deleting var supermarketFromRepo = _supermarketRepository.GetSupermarketById(supermarketId); // check supermarket not null if (supermarketFromRepo == null) { return(NotFound()); } // delete and save _supermarketRepository.DeleteSupermarket(supermarketFromRepo); if (!_supermarketRepository.Save()) { throw new Exception($"Deleting supermarket {supermarketId} and associated stock failed on save."); } return(NoContent()); }