public async Task <IActionResult> Update(string Id, [FromBody] CompanySingleDto entity) { try { entity.Id = Id; int rows = await _service.Update(entity);//得到影响行数 if (rows > 0) { return(OKAction(true, "更新成功")); } return(NotFoundAction(false, "更新失败!原因:影响行数为0")); } catch (Exception ex) { return(OKAction(false, $"更新失败!原因:{ex.Message}")); } }
public async Task <IActionResult> Insert([FromBody] CompanySingleDto entity) { try { var companys = await _service.QueryAsync <CompanySingleDto>(); if (companys.Find(it => it.EnCode == entity.EnCode) != null) { return(Ok(new { Status = false, Message = "此编码已存在,请重新输入" })); } int rows = await _service.Insert(entity);//得到影响行数 if (rows > 0) { return(CreateAction()); } return(OKAction(false, "创建失败!原因:影响行数为0")); } catch (Exception ex) { return(OKAction(false, $"创建失败!原因:{ex.Message}")); } }