public async Task <CreateShopAcceptorCommandResponse> Handle(CreateShopAcceptorCommand command)
        {
            var city = await _cityRepository.AsQuery().SingleOrDefaultAsync(p => p.Id == command.ShopAcceptorAddress.CityId);

            if (city == null)
            {
                throw new DomainException("شهر یافت نشد");
            }
            var userInfo = new UserInfo(command.UserInfo.UserId, command.UserInfo.FirstName,
                                        command.UserInfo.LastName);
            var shopAcceptorAddress = new ShopAcceptorAddress(command.ShopAcceptorAddress.AddressText,
                                                              command.ShopAcceptorAddress.CityId,
                                                              city.CityName);
            var shopAcceptor = new ShopAcceptor(Guid.NewGuid(), command.FirstName, command.LastName,
                                                command.PhoneNumber, command.MobileNumber, command.ShopName, userInfo, shopAcceptorAddress);

            _repository.Add(shopAcceptor);
            return(new CreateShopAcceptorCommandResponse());
        }
Пример #2
0
 public static IShopAcceptorsWithAddressDto ToDto(this ShopAcceptor src)
 {
     return(Mapper.Map <IShopAcceptorsWithAddressDto>(src));
 }