コード例 #1
0
ファイル: CreateCityCommand.cs プロジェクト: Emad-Sayed/DDD
            public async Task <string> Handle(CreateCityCommand request, CancellationToken cancellationToken)
            {
                var cityExist = await _customerRepository.CityExistAsync(request.Name);

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

                var city = new City(request.CityId, request.Name);

                _customerRepository.AddCity(city);

                await _customerRepository.UnitOfWork.SaveEntitiesAsync();

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