public ActionResult GetDevInfo(int?id) { DevInfoTrans recv = Activator.CreateInstance <DevInfoTrans>(); DevInfo dit = new DevInfo(); try { string url = "http://localhost:41363/api/DevInfo/1"; recv = TransClass.GetMethod <DevInfoTrans> .GetHasDateTime(url); DevInfo dit2 = new DevInfo(); dit2 = recv.data[0]; if (dit2 != null) { dit = dit2; } } catch (Exception ex) { string messgae = ex.Message; } return(View(dit)); }
public DevInfoTrans GetAllDevInfos() { DevInfoTrans send = new DevInfoTrans(); List <DevInfo> devinfoList = bll.DevInfos.ToList(); send.total = devinfoList.Count; send.msg = "ok"; send.data = devinfoList; return(send); }
public ActionResult GetAllDevInfos() { DevInfoTrans recv = Activator.CreateInstance <DevInfoTrans>(); try { string url = "http://localhost:41363/api/DevInfo"; recv = TransClass.GetMethod <DevInfoTrans> .GetHasDateTime(url); } catch (Exception ex) { string messgae = ex.Message; } return(View(recv.data)); }
public DevInfoTrans GetDevInfo(int?id) { DevInfoTrans send = new DevInfoTrans(); send.total = 1; send.msg = "ok"; if (id != null) { //DevInfo devinfo = bll.DevInfos.DbSet.Where(p=>p.Id == id).ToList()[0];//ToList结果为0个时会出异常,改为下面语句 //DevInfo devinfo = bll.DevInfos.DbSet.Where(p => p.Id == id).FirstOrDefault();//等效于下面语句 DevInfo devinfo = bll.DevInfos.DbSet.FirstOrDefault(p => p.Id == id); if (devinfo != null) { List <DevInfo> devinfoList = new List <DevInfo>(); devinfoList.Add(devinfo); send.data = devinfoList; } } return(send); }