Exemple #1
0
        public virtual ActionResult Unbind(StaffModel model)
        {
            var result = new Dictionary <string, object>();
            var entity = new StaffEntity
            {
                Id      = model.Id.Convert <long>(),
                Account = new AccountEntity {
                    Id = 0
                },
                SaveType = SaveType.Modify
            };

            entity.SetProperty(it => it.Account.Id);
            var rev = this.SaveEntity(entity);

            if (rev)
            {
                result.Add("Id", entity.Id.ToString());
            }
            else
            {
                result.Add("Message", entity.Errors?.FirstOrDefault()?.Message);
            }
            result.Add("Status", rev);
            return(this.Jsonp(result));
        }
Exemple #2
0
        /// <summary>
        /// 创建实体
        /// </summary>
        /// <param name="saveType"></param>
        /// <param name="account"></param>
        /// <returns></returns>
        public virtual StaffEntity CreateEntity(SaveType saveType, AccountEntity account)
        {
            var entity = new StaffEntity
            {
                Name       = Name,
                Department = new DepartmentEntity {
                    Id = DepartmentId.Convert <long>()
                },
                Account = new AccountEntity {
                    Id = account == null?0:account.Id
                },
                SaveType = saveType
            };

            if (ReadCustomerType != null)
            {
                entity.SetSetting("ReadCustomerType", (int)ReadCustomerType);
            }
            if (saveType == SaveType.Modify)
            {
                entity.Id = Id.Convert <long>();
                if (Name != null)
                {
                    entity.SetProperty(it => it.Name);
                }
                if (DepartmentId != null)
                {
                    entity.SetProperty(it => it.Department.Id);
                }
                if (ReadCustomerType != null)
                {
                    entity.SetProperty(it => it.Setting);
                }
                if (account != null)
                {
                    entity.SetProperty(it => it.Account.Id);
                }
            }
            entity.SerializeSetting();
            return(entity);
        }