Ejemplo n.º 1
0
        /// <summary>
        /// 创建实体
        /// </summary>
        /// <returns></returns>
        public virtual AddressEntity CreateEntity(SaveType saveType)
        {
            var entity = new AddressEntity
            {
                Country   = "中国",
                Province  = Province,
                City      = City,
                County    = County,
                Recipient = Recipient,
                Mobile    = Mobile,
                Postcode  = Postcode,
                Address   = Address,
                Telephone = Telephone,
                Company   = Company,
                IsDefault = IsDefault,
                Email     = Email,
                Tag       = Tag,
                SaveType  = saveType
            };

            if (saveType == SaveType.Modify)
            {
                entity.Id = Id;
                entity.SetProperty(it => it.Country).SetProperty(it => it.Province).SetProperty(it => it.City)
                .SetProperty(it => it.County).SetProperty(it => it.Recipient)
                .SetProperty(it => it.Mobile).SetProperty(it => it.Postcode)
                .SetProperty(it => it.Address).SetProperty(it => it.Telephone)
                .SetProperty(it => it.Company).SetProperty(it => it.IsDefault)
                .SetProperty(it => it.Email).SetProperty(it => it.Tag);
            }
            return(entity);
        }
Ejemplo n.º 2
0
        public virtual ActionResult UpdateDefault(long id)
        {
            var result          = new Dictionary <string, object>();
            var infos           = new List <AddressEntity>();
            var defaultEntities = GetDefaultInfos();

            if (defaultEntities != null)
            {
                foreach (var entity in defaultEntities)
                {
                    entity.IsDefault = false;
                    entity.SaveType  = SaveType.Modify;
                    entity.SetProperty(it => it.IsDefault);
                    infos.Add(entity);
                }
            }
            var info = new AddressEntity
            {
                Id        = id,
                IsDefault = true,
                SaveType  = SaveType.Modify
            };

            info.SetProperty(it => it.IsDefault);
            infos.Add(info);
            var rev = this.SaveEntities(infos);

            result.Add("Status", rev);
            return(this.Jsonp(result));
        }