コード例 #1
0
        protected override Account ExecuteProcedure()
        {
            var repository = Repository.Create <IAccountRepository>();
            var account    = repository.Find(_id, QueryLevel.Single);

            if (this.Name != null)
            {
                account.Name = this.Name;
            }
            if (this.Email != null)
            {
                account.Email = this.Email;
            }
            if (this.IsEnabled != null)
            {
                account.Status.IsEnabled = this.IsEnabled.Value;
            }
            if (this.MobileNumber != null)
            {
                account.MobileNumber = this.MobileNumber;
            }
            if (this.Password != null)
            {
                account.SetPasswordAndEncrypt(this.Password);
            }
            if (this.RoleIds != null)
            {
                var roles = RoleCommon.FindsBy(this.RoleIds);
                account.Roles = roles;
            }
            repository.Update(account);
            return(account);
        }
コード例 #2
0
        protected override Account ExecuteProcedure()
        {
            var roles = _roleIds != null && _roleIds.Count() > 0 ? RoleCommon.FindsBy(_roleIds) : Array.Empty <Role>();

            Account acc = new Account(_name, _password, roles)
            {
                Email        = this.Email ?? string.Empty,
                MobileNumber = this.MobileNumber ?? string.Empty
            };

            acc.Status.IsEnabled = this.IsEnabled ?? true;

            var repository = Repository.Create <IAccountRepository>();

            repository.Add(acc);

            return(acc);
        }