示例#1
0
            public async Task <string> Handle(CreateCityCommand request, CancellationToken cancellationToken)
            {
                var cityExist = await _distributorRepository.CityExistAsync(request.Name);

                if (cityExist)
                {
                    throw new CityAlreadyExistException(request.Name);
                }

                var city = new City(Guid.NewGuid().ToString(), request.Name);

                _distributorRepository.AddCity(city);

                await _distributorRepository.UnitOfWork.SaveEntitiesAsync();

                return(city.Id.ToString());
            }