public ContentResult saveAgent(string jsonString) { AjaxResult res = new AjaxResult(); try { WF_Agent agent = jsonString.ToObject <WF_Agent>(); WF_Agent entity = agentbll.getByID(agent.ID); if (entity != null) { agent.UpdateTime = DateTime.Now; agent.UpdateUserCode = getCurrent().UserCode; agent.CreateTime = entity.CreateTime; agent.CreateUserCode = entity.CreateUserCode; agent.IsDelete = entity.IsDelete; agentbll.update(agent); } else { agent.UpdateTime = DateTime.Now; agent.UpdateUserCode = getCurrent().UserCode; agent.CreateTime = DateTime.Now; agent.CreateUserCode = getCurrent().UserCode; agent.IsDelete = 0; agentbll.save(agent); } res.code = ResultCode.OK; } catch (Exception ex) { res.code = ResultCode.ERROR; res.message = "保存失败"; } return(Content(res.ToJson())); }
public bool update(WF_Agent entity) { using (IDbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["wfdb"].ToString())) { conn.Open(); return(conn.Update <WF_Agent>(entity)); } }
public bool save(WF_Agent entity) { using (IDbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["wfdb"].ToString())) { conn.Open(); conn.Insert <WF_Agent>(entity); return(true); } }
public bool del(int id) { using (IDbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["wfdb"].ToString())) { conn.Open(); WF_Agent agent = conn.Get <WF_Agent>(id); agent.IsDelete = 1; return(conn.Update <WF_Agent>(agent)); } }
public ContentResult updateAgentstate(int id, int state) { AjaxResult res = new AjaxResult(); try { WF_Agent entity = agentbll.getByID(id); if (entity != null) { entity.State = state; agentbll.update(entity); } res.code = ResultCode.OK; res.message = "更新状态成功"; } catch (Exception ex) { res.code = ResultCode.ERROR; res.message = "更新状态失败"; } return(Content(res.ToJson())); }
public ContentResult getAgentByID(int id) { AjaxResult res = new AjaxResult(); try { WF_Agent agent = agentbll.getByID(id); if (agent == null) { agent = new WF_Agent(); agent.ID = id; agent.State = 1; } res.code = ResultCode.OK; res.data = agent; } catch (Exception ex) { res.code = ResultCode.ERROR; res.message = "获取代理人信息失败"; } return(Content(res.ToJson())); }
public bool update(WF_Agent entity) { return(dao.update(entity)); }
public bool save(WF_Agent entity) { return(dao.save(entity)); }