コード例 #1
0
        public async Task <ResultDto> Delete(int id)
        {
            var result = new ResultDto {
                Message = ""
            };

            try
            {
                var player = await _playerDomainService.Get(id);

                if (player == null)
                {
                    result.Message = $"玩家 {id} 不存在!";
                    return(result);
                }


                await _playerDomainService.Delete(player);

                await _operatorLogDomainService.AddSuccess(new OperatorLogEntity
                {
                    Type    = OperatorLogType.除玩家,
                    Content = JsonConvert.SerializeObject(player)
                });

                await Commit();

                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                await _operatorLogDomainService.AddError(new OperatorLogEntity
                {
                    Type    = OperatorLogType.除玩家,
                    Content = $"id={id},ErrorMessage={result.Message}"
                });
                await Commit();
            }
            return(result);
        }