コード例 #1
0
ファイル: StoreController.cs プロジェクト: zanderphh/Shop
        public async Task <BaseApiResponse> EditStatus(EditStatusRequest request)
        {
            request.CheckNotNull(nameof(request));

            var store = _storeQueryService.Info(request.Id);

            if (store == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "未找到店铺"
                });
            }
            var command = new UpdateStoreStautsCommand(
                request.Status)
            {
                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, "{0}=>{1}".FormatWith(store.Status.ToDescription(), request.Status.ToDescription()));
            return(new BaseApiResponse());
        }
コード例 #2
0
ファイル: StoreController.cs プロジェクト: zanderphh/Shop
        public async Task <BaseApiResponse> EditStatus([FromBody] EditStatusRequest request)
        {
            request.CheckNotNull(nameof(request));

            var command = new UpdateStoreStautsCommand(
                request.Status)
            {
                AggregateRootId = request.Id
            };

            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
コード例 #3
0
ファイル: StoreCommandHandler.cs プロジェクト: zanderphh/Shop
 public void Handle(ICommandContext context, UpdateStoreStautsCommand command)
 {
     context.Get <Store>(command.AggregateRootId).UpdateStatus(command.Status);
 }