public async Task <ApiResult <string> > Delete(int id) { var r = new ApiResult <string>(); try { var isExist = await _testServices.IsExist(id); if (isExist) { r.status = await _testServices.DeleteById(id) > 0 ? 200 : 400; r.msg = r.status == 200 ? "删除成功" : "删除失败"; } else { r.status = 400; r.msg = "未匹配到数据"; } } catch (Exception ex) { r.status = 500; r.msg = ex.Message; } return(r); }
public async Task <MessageModel <string> > Delete(long id) { var data = new MessageModel <string>(); var eneity = await _testServices.GetById(id); if (eneity != null) { data.success = await _testServices.DeleteById(id); data.msg = data.success ? "删除成功" : "删除失败"; } else { data.status = 204; data.msg = "未找到数据"; } return(data); }