Beispiel #1
0
        public async Task <BaseApiResponse> DeleteExpressAddress([FromBody] DeleteRequest request)
        {
            request.CheckNotNull(nameof(request));
            var currentAccount = _contextService.GetCurrentAccount(HttpContext);

            var command = new RemoveExpressAddressCommand(currentAccount.UserId.ToGuid(), request.Id);
            var result  = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
Beispiel #2
0
        public async Task <BaseApiResponse> DeleteExpressAddress(DeleteExpressAddressRequest request)
        {
            request.CheckNotNull(nameof(request));

            TryInitUserModel();

            var command = new RemoveExpressAddressCommand(_user.Id, request.ExpressAddressId);
            var result  = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
Beispiel #3
0
 public void Handle(ICommandContext context, RemoveExpressAddressCommand command)
 {
     context.Get <User>(command.AggregateRootId).RemoveExpressAddress(command.ExpressAddressId);
 }