Example #1
0
            public async Task <Unit> Handle(DeleteCityCommand request, CancellationToken cancellationToken)
            {
                // get distributor by id
                var city = await _distributorRepository.FindCityByIdAsync(request.CityId);

                if (city == null)
                {
                    throw new CityNotFoundException(request.CityId);
                }

                city.DeleteCity();

                _distributorRepository.DeleteCity(city);

                // save changes in the database and rase DistributorUpdated event
                await _distributorRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);

                return(Unit.Value);
            }