Exemplo n.º 1
0
 public async Task <IActionResult> Edit(RuleEditDto barcodeRule)
 {
     if (barcodeRule.Id <= 0)
     {
         return(Json(new ResultEntity {
             Message = "请求数据有误,修改数据空主键"
         }));
     }
     return(await CreateOrUpdate(barcodeRule));
 }
Exemplo n.º 2
0
        private async Task <IActionResult> CreateOrUpdate(RuleEditDto barcodeRule)
        {
            var result = new ResultEntity();

            if (ModelState.IsValid)
            {
                barcodeRule.SetCreateOrUpdateInfo(CurrentUser.UserId);
                result = await _ruleAppService.AddOrUpdateAsync(barcodeRule);

                return(Json(result));
            }
            result.Message = ModelState.Values
                             .FirstOrDefault(a => a.ValidationState == ModelValidationState.Invalid)?.Errors.FirstOrDefault()
                             ?.ErrorMessage;

            return(Json(result));
        }
Exemplo n.º 3
0
        public async Task <ResultEntity> AddOrUpdateAsync(RuleEditDto editDto)
        {
            var barcodeRule = Mapper.Map <Rule>(editDto);
            var result      = await _barcodeRuleManager.AddOrUpdateAsync(barcodeRule);

            if (result.Success)
            {
                await _unitOfWork.CommitAsync();

                if (editDto.Id > 0)
                {
                    await _logManager.LogInfomationAsync(EnumLogType.Audit, LogTitleConstString.BarcodeRuleEdit,
                                                         $"【{editDto.Name}】", JsonConvert.SerializeObject(barcodeRule), editDto.CreateBy);
                }
                else
                {
                    await _logManager.LogInfomationAsync(EnumLogType.Audit, LogTitleConstString.BarcodeRuleAdd,
                                                         $"【{editDto.Name}】", JsonConvert.SerializeObject(barcodeRule), editDto.CreateBy);
                }
            }
            return(result);
        }