Example #1
0
        public async Task <Response> AddEditShipping(UserShippingAddress detail, string action)
        {
            var data   = JsonConvert.SerializeObject(detail);
            var result = await CallPostFunction(data, action);

            return(result);
        }
Example #2
0
 public bool Update()
 {
     int cid = _address.Consignee_Id;
     Tnet_Consignee daConsignee = new Tnet_Consignee();
     if (!daConsignee.SelectByPk(cid))
     {
         Alert("指定修改的收货人信息不存在");
         return false;
     }
     BeginTransaction();
     ConsigneeCreationProvider creationProvider = new ConsigneeCreationProvider(_address);
     creationProvider.ReferenceTransactionFrom(Transaction);
     if (!creationProvider.Create())
     {
         Rollback();
         Alert("更新收货地址失败,请重试!");
         return false;
     }
     var oldAddress = _address;
     this._address = creationProvider.ShippingAddress;//new shipping address
     ConsigneeDeleteProvider deleteProvider = new ConsigneeDeleteProvider(oldAddress.Address_Id, oldAddress.User_Id);//delete old shipping address
     deleteProvider.ReferenceTransactionFrom(Transaction);
     if (!deleteProvider.Delete())
     {
         Rollback();
         Alert("更新收货地址失败,请重试!");
         return false;
     }
     Commit();
     return true;
 }
Example #3
0
        public bool SetDefault(int address_id)
        {
            UserShippingAddress address = new UserShippingAddress();

            address.Address_Id = address_id;
            ConsigneeUpdateProvider updateProvider = new ConsigneeUpdateProvider(address);

            return(updateProvider.SetDefault());
        }
        /// <summary>
        /// 生成完整的收货地址字符串
        /// </summary>
        /// <param name="address">收货地址</param>
        /// <returns></returns>
        public static string GenerateSummary(this UserShippingAddress address)
        {
            // 获取国家和地区名称
            // 如果设置了不显示国家下拉框,则国家名称等于空
            var regionManager = Application.Ioc.Resolve <RegionManager>();
            var configManager = Application.Ioc.Resolve <GenericConfigManager>();
            var country       = regionManager.GetCountry(address.Country) ?? regionManager.GetDefaultCountry();
            var region        = (address.RegionId == null ? null :
                                 country.GetRegionsTreeNode(address.RegionId.Value));
            var regionSettings = configManager.GetData <RegionSettings>();
            var countryName    = regionSettings.DisplayCountryDropdown ? new T(country.Name) : "";
            var regionName     = region == null ? null : region.GetFullname();

            // 生成完整的收货地址字符串
            return(string.Format("{0} {1}{2}{3} {4}",
                                 address.ReceiverName, countryName, regionName,
                                 address.DetailedAddress, address.ReceiverTel));
        }
Example #5
0
        public async Task <UserShippingAddress> GetAddressById(string Id)
        {
            var query = string.Empty;

            query = "{\"Id\":\"IdValue\"}";
            query = query.Replace("IdValue", Id);
            var result = await CallPostFunction(query, GetAddressByIdAction);

            if (result == null || !result.Status)
            {
                return(null);
            }
            else
            {
                var detail = new UserShippingAddress();
                detail = JsonConvert.DeserializeObject <UserShippingAddress>(result.ResponseValue);
                return(detail);
            }
        }
        /// <summary>
        /// 保存收货地址的修改
        /// </summary>
        protected virtual void SaveShippingAddress()
        {
            var addressId = Parameters.OrderParameters.GetSaveShipppingAddressId();

            if (addressId == null || Parameters.UserId == null)
            {
                return;
            }
            // 获取原地址,获取时同时检查所属用户
            var addressRepository = RepositoryResolver.Resolve <UserShippingAddress>(Context);
            var existAddress      = addressId > 0 ?
                                    addressRepository.Get(a => a.Id == addressId && a.User.Id == Parameters.UserId) : null;

            if (existAddress == null)
            {
                var userRepository = RepositoryResolver.Resolve <User>(Context);
                existAddress = new UserShippingAddress()
                {
                    User       = userRepository.GetById(Parameters.UserId),
                    CreateTime = DateTime.UtcNow
                };
            }
            // 更新或创建收货地址
            var newAddress = Parameters.OrderParameters.GetShippingAddress();

            addressRepository.Save(ref existAddress, address => {
                address.ReceiverName    = newAddress.ReceiverName;
                address.ReceiverTel     = newAddress.ReceiverTel;
                address.Country         = newAddress.Country;
                address.RegionId        = newAddress.RegionId;
                address.ZipCode         = newAddress.ZipCode;
                address.DetailedAddress = newAddress.DetailedAddress;
                address.LastUpdated     = DateTime.UtcNow;
                address.GenerateSummary();
            });
        }
Example #7
0
        public bool Update(UserShippingAddress address)
        {
            ConsigneeUpdateProvider updateProvider = new ConsigneeUpdateProvider(address);

            return(updateProvider.Update());
        }
Example #8
0
        public bool Create(UserShippingAddress address)
        {
            ConsigneeCreationProvider creationProvider = new ConsigneeCreationProvider(address);

            return(creationProvider.Create());
        }
Example #9
0
 public ConsigneeUpdateProvider(UserShippingAddress address)
 {
     this._address = address;
 }
Example #10
0
 public ConsigneeCreationProvider(UserShippingAddress address)
 {
     this._address = address;
 }