public bool Add(ServiceInfoAddParams dto, string teamNumber, ref string errorMsg) { var isExist = this.ServiceInfoRepository.Queryable() .Any(x => x.IsDeleted == false && x.ServiceNumber == dto.ServiceNumber); if (isExist) { errorMsg = $"该服务编号为:{dto.ServiceNumber}的服务已存在"; return(false); } var entity = new ServiceInfo { ServiceCode = dto.ServiceCode, ServiceNumber = dto.ServiceNumber, IsDeleted = false, Remark = dto.Remark, TeamNumber = teamNumber.Trim(), CreatedBy = "admin", CreatedTime = DateTime.Now, ModifiedBy = "admin", ModifiedTime = DateTime.Now }; return(ServiceInfoRepository.Add(entity) > 0); }
// POST: api/ServiceInfo public StandardJsonResult Post([FromBody] ServiceInfoAddParams param) { string errorMsg = string.Empty; bool isSuccess = false; var standardJsonResult = StandardAction(() => { var teamNumber = (string)HttpContext.Current.Session["loginUser"]; isSuccess = this.ServiceInfoService.Add(param, teamNumber, ref errorMsg); }); standardJsonResult.Success = isSuccess; if (string.IsNullOrEmpty(standardJsonResult.Message)) { standardJsonResult.Message = isSuccess ? "添加成功" : (string.IsNullOrEmpty(errorMsg) ? "添加失败" : errorMsg); } return(standardJsonResult); }