public IHttpActionResult AddCustomer() { string name = requestHelper.GetRequsetForm("customerName", ""); string tel = requestHelper.GetRequsetForm("tel", ""); if (string.IsNullOrEmpty(name)) { return(Ok(ReturnJsonResult.ToJson(-1, "客户名称不能为空!", ""))); } if (string.IsNullOrEmpty(tel)) { return(Ok(ReturnJsonResult.ToJson(-1, "联系电话不能为空!", ""))); } Model.Customers model = new Model.Customers(); model.CustomerName = name; model.Tel = tel; int i = bll.Add(model); if (i > 0) { return(Ok(ReturnJsonResult.ToJson(1, "添加成功!", ""))); } return(Ok(ReturnJsonResult.ToJson(-1, "添加失败!", ""))); }
public IHttpActionResult DeleteCustomer() { string kidList = requestHelper.GetRequsetForm("kidList", ""); if (string.IsNullOrEmpty(kidList)) { return(Ok(ReturnJsonResult.ToJson(-1, "请选中要删除的项!", ""))); } bool b = bll.DeleteList(kidList); if (b) { return(Ok(ReturnJsonResult.ToJson(1, "删除成功!", ""))); } return(Ok(ReturnJsonResult.ToJson(-1, "删除失败!", ""))); }
public IHttpActionResult GetCustomerById(int id) { try { Weiz.WebApi.Model.Customers customer = bll.GetModel(id); if (customer != null) { return(Ok(ReturnJsonResult.ToJson(-1, "数据不存在!", customer))); } return(Ok(ReturnJsonResult.ToJson(1, "", customer))); } catch (Exception myex) { throw myex; } }
public IHttpActionResult GetCustomerList() { try { List <Weiz.WebApi.Model.Customers> list = bll.GetModelList(""); if (list.Count <= 0) { return(Ok(ReturnJsonResult.ToJson(-1, "数据不存在!", list))); } return(Ok(ReturnJsonResult.ToJson(1, "", list))); } catch (Exception myex) { throw myex; } }
public IHttpActionResult GetCustomerDT() { try { DataTable dt = bll.GetList("").Tables[0]; if (dt.Rows.Count <= 0) { return(Ok(ReturnJsonResult.ToJson(-1, "数据不存在!", dt))); } return(Ok(ReturnJsonResult.ToJson(1, "", dt))); } catch (Exception myex) { throw myex; } }
public IHttpActionResult GetCustomerVar() { List <Weiz.WebApi.Model.Customers> list = bll.GetModelList(""); var result = from c in list select new { Kid = c.Kid, CustomerName = c.CustomerName, Tel = c.Tel }; if (result.Count() <= 0) { return(Ok(ReturnJsonResult.ToJson(-1, "数据不存在!", list))); } return(Ok(ReturnJsonResult.ToJson(1, "", list))); }