コード例 #1
0
ファイル: StoreCommandHandler.cs プロジェクト: zanderphh/Shop
 public void Handle(ICommandContext context, CustomerUpdateStoreCommand command)
 {
     context.Get <Store>(command.AggregateRootId).CustomerUpdate(new StoreCustomerEditableInfo(
                                                                     command.Name,
                                                                     command.Description,
                                                                     command.Address
                                                                     ));
 }
コード例 #2
0
        public async Task <BaseApiResponse> EditStore([FromBody] EditRequest request)
        {
            request.CheckNotNull(nameof(request));

            var command = new CustomerUpdateStoreCommand(
                request.Name,
                request.Description,
                request.Address)
            {
                AggregateRootId = request.Id
            };

            var result = await ExecuteCommandAsync(command);

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