Пример #1
0
        public async Task <ResultDto> Add(QuestInput item)
        {
            var result = new ResultDto {
                Message = ""
            };

            try
            {
                var itemDrop = _mapper.Map <QuestEntity>(item);


                await _questDomainService.Add(itemDrop);

                await _operatorLogDomainService.AddSuccess(new OperatorLogEntity
                {
                    Type    = OperatorLogType.添加任务,
                    Content = JsonConvert.SerializeObject(item)
                });

                await Commit();

                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                await _operatorLogDomainService.AddError(new OperatorLogEntity
                {
                    Type    = OperatorLogType.添加任务,
                    Content = $"Data={JsonConvert.SerializeObject(item)},ErrorMessage={result.Message}"
                });
                await Commit();
            }
            return(result);
        }
Пример #2
0
        public async Task <ResultDto> Update(int id, QuestInput item)
        {
            var result = new ResultDto {
                Message = ""
            };

            try
            {
                var map = await _questDomainService.Get(id);

                if (map == null)
                {
                    result.Message = $"任务 {id} 不存在!";
                    return(result);
                }

                var content = map.ComparisonTo(item);
                _mapper.Map(item, map);

                await _questDomainService.Update(map);

                await _operatorLogDomainService.AddSuccess(new OperatorLogEntity
                {
                    Type    = OperatorLogType.修改任务,
                    Content = $"Id = {id},Data = {content}"
                });

                await Commit();

                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                await _operatorLogDomainService.AddError(new OperatorLogEntity
                {
                    Type    = OperatorLogType.修改任务,
                    Content = $"Data={JsonConvert.SerializeObject(item)},ErrorMessage={result.Message}"
                });
                await Commit();
            }
            return(result);
        }