Esempio n. 1
0
        public void UpdateUserInfo(UpdateUserParam param)
        {
            var user = _repository.FirstOrDefault(CurrentUsers.Uid);

            user.ScreenName = param.ScreenName;
            user.Email      = param.Email;
            _repository.SaveChanges();
        }
Esempio n. 2
0
        /// <summary>
        /// 更新用户信息
        /// </summary>
        /// <param name="updates">更新项</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <User> UpdateProfile(
            UpdateUserInput updates,
            CancellationToken cancellationToken = default)
        {
            var param = new UpdateUserParam(updates);
            var res   = await Request <UpdateUserResponse>(param.CreateRequest(), cancellationToken);

            User = res.Result;
            return(res.Result);
        }
 /// <summary>
 /// 注销
 /// </summary>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public async Task Logout(CancellationToken cancellationToken = default)
 {
     await CheckLoggedIn();
     var param = new UpdateUserParam()
     {
         Id = CurrentUser.Id,
         Input = new UpdateUserInput()
         {
             TokenExpiredAt = "0",
         }
     };
     await Request<UpdateUserResponse>(param.CreateRequest(), cancellationToken);
     CurrentUser = null;
 }
Esempio n. 4
0
            /// <summary>
            /// 更新用户信息
            /// </summary>
            /// <param name="userId">用户 ID</param>
            /// <param name="updates">更新信息</param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public async Task <User> Update(
                string userId,
                UpdateUserInput updates,
                CancellationToken cancellationToken = default)
            {
                updates.Password = client.Encrypt(updates.Password);
                var param = new UpdateUserParam(updates)
                {
                    Id    = userId,
                    Input = updates
                };

                var res = await client.Request <UpdateUserResponse>(param.CreateRequest(), cancellationToken);

                return(res.Result);
            }
Esempio n. 5
0
        /// <summary>
        /// Update User infos
        /// </summary>
        /// <param name="param">The Repository call params <see cref="UpdateUserParam"/></param>
        /// <returns>
        /// The updated Customer and a status representing a possible cause of errors
        /// </returns>
        public virtual async Task <Customer> UpdateUserAsync(UpdateUserParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.Customer == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.Customer)), nameof(param));
            }

            var request = new UpdateCustomerRequest(param.Customer)
            {
                ScopeId = param.Scope
            };

            var updatedCustomer = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            return(updatedCustomer);
        }
        /// <summary>
        /// Update the account informations.
        /// </summary>
        /// <param name="param">Builder params <see cref="UpdateAccountParam"/></param>
        /// <returns></returns>
        public async virtual Task <UpdateAccountViewModel> UpdateAccountAsync(UpdateAccountParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Email))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Email)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.FirstName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.FirstName)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.LastName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.LastName)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.PreferredLanguage))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.PreferredLanguage)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }

            var customer = await CustomerRepository.GetCustomerByIdAsync(new GetCustomerByIdParam
            {
                Scope       = param.Scope,
                CustomerId  = param.CustomerId,
                CultureInfo = param.CultureInfo
            }).ConfigureAwait(false);

            if (customer == null)
            {
                return(null);
            }

            UpdateCustomerInfo(customer, param);

            var updateUserParam = new UpdateUserParam
            {
                Customer = customer,
                Scope    = param.Scope
            };

            var updatedCustomer = await CustomerRepository.UpdateUserAsync(updateUserParam).ConfigureAwait(false);

            var getUpdateAccountViewModelParam = new GetUpdateAccountViewModelParam
            {
                Status      = MyAccountStatus.Success,
                CultureInfo = param.CultureInfo,
                ReturnUrl   = param.ReturnUrl
            };

            return(GetUpdateAccountViewModel(getUpdateAccountViewModelParam, updatedCustomer));
        }
Esempio n. 7
0
 public ApiResponse Info(UpdateUserParam param)
 {
     _userService.UpdateUserInfo(param);
     return(ApiResponse.Ok());
 }
Esempio n. 8
0
        public UpdateUserResult UpdateUser(UpdateUserParam updateUserParam)
        {
            var result = _restHelper.Post <UpdateUserParam, UpdateUserResult>("/api/v1/users.update", updateUserParam, _headers);

            return(result);
        }