Example #1
0
 public ShopAcceptor(Guid id, string firstName, string lastName, string phoneNumber, string mobileNumber, string shopName, UserInfo userInfo, ShopAcceptorAddress shopAcceptorAddress)
 {
     Id                  = id;
     FirstName           = firstName;
     LastName            = lastName;
     PhoneNumber         = phoneNumber;
     MobileNumber        = mobileNumber;
     ShopName            = shopName;
     CreationTime        = DateTime.Now;
     UserInfo            = userInfo;
     ShopAcceptorAddress = shopAcceptorAddress;
     ShopAcceptorStatus  = ShopAcceptorStatus.Pending;
 }
        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());
        }