public List <FullPackagePlan> GetLoadedPackageByPallet(int palletId) { ShippmentEntities db = new ShippmentEntities(); List <FullPackagePlan> list = new List <FullPackagePlan>(); PalletDefine pallet = db.PalletDefines.FirstOrDefault(p => p.Id == palletId && !p.IsDeleted); if (pallet != null) { foreach (var pp in pallet.PackagePlans) { FullPackagePlan plan = new FullPackagePlan(); plan.Id = pp.PackageDefineId; plan.pkgQty = pp.Qty; plan.palletDefineId = pp.PalletDefineId; plan.Material = pp.PackageDefine.Material; plan.Length_mm = pp.PackageDefine.Length_mm; plan.Width_mm = pp.PackageDefine.Width_mm; plan.Height_mm = pp.PackageDefine.Height_mm; plan.NetWeight_kg = pp.PackageDefine.NetWeight_kg; plan.GrossWeight_kg = pp.PackageDefine.GrossWeight_kg; plan.Note = pp.PackageDefine.Note; plan.PartNo = pp.PackageDefine.PartNo; plan.Qty = pp.PackageDefine.Qty; plan.Unit = pp.PackageDefine.Unit; list.Add(plan); } } return(list); }
public ErrorInfo Edit(int id, PalletDefine palletDefine) { if (id != palletDefine.Id) { return(ErrorInfo.Err_Bad_Request_Information); } ShippmentEntities db = new ShippmentEntities(); PalletDefine pallet = db.PalletDefines.FirstOrDefault(p => p.Id == id && !p.IsDeleted); if (pallet != null) { pallet.Material = palletDefine.Material; pallet.Length_mm = palletDefine.Length_mm; pallet.Width_mm = palletDefine.Width_mm; pallet.Height_mm = palletDefine.Height_mm; pallet.NetWeight_kg = palletDefine.NetWeight_kg; pallet.GrossWeight_kg = palletDefine.GrossWeight_kg; pallet.Note = palletDefine.Note; pallet.IsDeleted = palletDefine.IsDeleted; db.Entry(pallet).State = System.Data.Entity.EntityState.Modified; if (db.SaveChanges() > 0) { return(ErrorInfo.Succeed); } else { return(ErrorInfo.Err_Internal_Error); } } else { return(ErrorInfo.Err_Resource_NotExist); } }
public PalletDefine Get(int id) { ShippmentEntities db = new ShippmentEntities(); PalletDefine pallet = (from p in db.PalletDefines where p.Id == id && !p.IsDeleted select p).FirstOrDefault(); return(pallet); }
public ErrorInfo Add(PalletDefine palletDefine) { ShippmentEntities db = new ShippmentEntities(); db.PalletDefines.Add(palletDefine); if (db.SaveChanges() > 0) { return(ErrorInfo.Succeed); } else { return(ErrorInfo.Err_Internal_Error); } }
public ErrorInfo Delete(int id) { ShippmentEntities db = new ShippmentEntities(); PalletDefine pallet = db.PalletDefines.FirstOrDefault(p => p.Id == id); if (pallet != null) { pallet.IsDeleted = true; db.Entry(pallet).State = System.Data.Entity.EntityState.Modified; if (db.SaveChanges() > 0) { return(ErrorInfo.Succeed); } else { return(ErrorInfo.Err_Internal_Error); } } else { return(ErrorInfo.Err_Resource_NotExist); } }