public NewErrorModel Modify(ProductionOrderTable productionOrderTable) { try { DDContext dDContext = new DDContext(); dDContext.Entry <ProductionOrderTable>(productionOrderTable).State = System.Data.Entity.EntityState.Modified; if (productionOrderTable.ProductionOrderDetails != null && productionOrderTable.ProductionOrderDetails.Count > 0) { foreach (var item in productionOrderTable.ProductionOrderDetails) { dDContext.Entry <ProductionOrderDetail>(item).State = System.Data.Entity.EntityState.Modified; } } dDContext.SaveChanges(); return(new NewErrorModel() { error = new Error(0, "修改成功!", "") { }, }); } catch (Exception ex) { throw ex; } }
public NewErrorModel Save(ProductionOrderTable productionOrderTable) { try { DDContext dDContext = new DDContext(); if (productionOrderTable.ProductionOrderDetails == null || productionOrderTable.ProductionOrderDetails.Count == 0) { return(new NewErrorModel() { error = new Error(1, "ProductionOrderDetail参数有误!", "") { }, }); } else { dDContext.ProductionOrderTable.Add(productionOrderTable); dDContext.ProductionOrderDetail.AddRange(productionOrderTable.ProductionOrderDetails); dDContext.SaveChanges(); } return(new NewErrorModel() { error = new Error(0, "保存成功!", "") { }, }); } catch (Exception ex) { throw ex; } }
public NewErrorModel Read(string taskId) { try { DDContext dDContext = new DDContext(); ProductionOrderTable productionOrderTable = dDContext.ProductionOrderTable.Where(t => t.TaskId == taskId).FirstOrDefault(); productionOrderTable.ProductionOrderDetails = dDContext.ProductionOrderDetail.Where(t => t.TaskId == taskId).ToList(); return(new NewErrorModel() { data = productionOrderTable, error = new Error(0, "读取成功!", "") { }, }); } catch (Exception ex) { throw ex; } }