public MeterialTrans GetMeterials(int?id) { MeterialTrans send = new MeterialTrans(); send.total = 1; send.msg = "ok"; if (id != null) { List <Meterial> meterialList = bll.Meterials.DbSet.Where(p => p.phtId == id).ToList(); List <MeterialOther> meterialOtherList = new List <MeterialOther>(); foreach (Meterial item in meterialList) { MeterialOther item2 = new MeterialOther(); item2.Id = item.Id; item2.Name = item.Name; item2.qty = item.qty; item2.unit = item.unit; item2.loc = item.pht.Name; meterialOtherList.Add(item2); } send.data = meterialOtherList; } return(send); }
public ActionResult GetMeterials() { MeterialTrans recv = Activator.CreateInstance <MeterialTrans>(); List <Meterial> meterialList = new List <Meterial>(); try { string url = "http://localhost:41363/api/Meterial/1"; recv = TransClass.GetMethod <MeterialTrans> .Get(url); foreach (MeterialOther item in recv.data) { Meterial item2 = new Meterial(); item2.Id = item.Id; item2.Name = item.Name; item2.qty = item.qty; item2.unit = item.unit; item2.pht = bll.PhysicalTopologys.DbSet.Where(p => p.Name == item.loc).ToList()[0]; item2.phtId = item2.pht.Id; meterialList.Add(item2); } } catch (Exception ex) { string messgae = ex.Message; } return(View(meterialList)); }