Esempio n. 1
0
        public async Task <BaseApiResponse> SetRegion(SetRegionRequest request)
        {
            request.CheckNotNull(nameof(request));
            TryInitUserModel();

            //更新
            var command = new UpdateRegionCommand(request.Region)
            {
                AggregateRootId = _user.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }

            //更新缓存
            _user.Region = request.Region;
            _apiSession.UpdateUserInfo(_user.Id.ToString(), _user);

            return(new BaseApiResponse());
        }
Esempio n. 2
0
        public async Task <BaseApiResponse> SetRegion([FromBody] SetRegionRequest request)
        {
            request.CheckNotNull(nameof(request));
            var currentAccount = _contextService.GetCurrentAccount(HttpContext);

            //更新
            var command = new UpdateRegionCommand(request.Region)
            {
                AggregateRootId = currentAccount.UserId.ToGuid()
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }