public async Task <BaseResponse> AddTypeModuleFeedbaskAsync(string Account, TypeModuleFeedbackAddDto req) { var count = await _tmfr.Find(a => a.ModuleControlId == req.ModuleControlId && a.DataDefineId == req.DataDefineId).CountAsync(); if (count > 0) { return(new BaseResponse { Success = false, Message = "已添加过相同的数据" }); } try { var entity = _map.Map <TypeModuleFeedbackModel>(req); entity.Create = Account; await _tmfr.AddAsync(entity); _log.LogInformation($"{Account}添加标示为{entity.Id}的反馈数据成功"); return(new HandleResponse <int> { Success = true, Message = "添加数据成功", Key = entity.Id }); } catch (Exception ex) { _log.LogError($"{Account}添加标示为{req.ModuleControlId}的控制项的反馈数据失败,失败原因:{ex.Message}->{ex.StackTrace}->{ex.InnerException}"); return(new BaseResponse { Success = false, Message = "添加数据失败,请联系管理员" }); } }
public async Task <ActionResult <BaseResponse> > AddTypeModuleFeedbackAsync(int typeId, TypeModuleFeedbackAddDto req) { string Account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value; #region 检测类型 var type = await _ts.CheckTypeAsync(typeId); if (!type.IsExist) { return(new BaseResponse { Success = false, Message = "输入的类型编号不存在" }); } if (type.Status == 0) { return(new BaseResponse { Success = false, Message = "该类型为目录型节点,不允许添加数据" }); } #endregion #region 检测数据定义标示是否存在 var td = await _td.IsExist(a => a.Id == req.DataDefineId); if (!td) { return(new BaseResponse { Success = false, Message = "输入的类型数据定义不存在" }); } #endregion #region 检测相关的控制项是否存在 var exist = await _tmcs.IsExist(a => a.Id == req.ModuleControlId); if (!exist) { return(new BaseResponse { Success = false, Message = "输入的控制项不存在" }); } #endregion var rm = await _tfs.AddTypeModuleFeedbaskAsync(Account, req); return(rm); }