예제 #1
0
        public async Task <BaseApiResponse> Edit(EditPartnerRequest request)
        {
            request.CheckNotNull(nameof(request));
            //判断
            var partner = _partnerQueryService.Find(request.Id);

            if (partner == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没找到该代理"
                });
            }

            var command = new UpdatePartnerCommand(
                request.Mobile,
                request.Region,
                request.Level,
                request.Persent,
                request.CashPersent,
                request.BalanceInterval,
                request.Remark,
                request.IsLocked
                )
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            //添加操作记录
            var currentAdmin = _contextService.GetCurrentAdmin(HttpContext.Current);

            RecordOperat(currentAdmin.AdminId.ToGuid(), "编辑代理", request.Id, request.Region);

            return(new BaseApiResponse());
        }
예제 #2
0
        public async Task <BaseApiResponse> Edit([FromBody] EditPartnerRequest request)
        {
            request.CheckNotNull(nameof(request));
            //判断
            var partner = _partnerQueryService.Find(request.Id);

            if (partner == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没找到该代理"
                });
            }

            var command = new UpdatePartnerCommand(
                request.Mobile,
                request.Region,
                request.Level,
                request.Persent,
                request.CashPersent,
                request.BalanceInterval,
                request.Remark,
                request.IsLocked
                )
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

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