public bool Edit(ImportedInventory newInstance) { var db = new MaterialMeasurementEntities(); try { var currentInstance = db.ImportedInventories.FirstOrDefault(m => m.ID == newInstance.ID); if (currentInstance == null) { return(false); } currentInstance.MaterialID = newInstance.MaterialID; currentInstance.ParcelCode = newInstance.ParcelCode; currentInstance.ImportDate = newInstance.ImportDate; currentInstance.Quantity = newInstance.Quantity; currentInstance.WeightUnit = newInstance.WeightUnit; db.Entry(currentInstance).State = System.Data.Entity.EntityState.Modified; SaveChanges(db); } catch (Exception) { return(false); } return(true); }
public bool Add(ImportedInventory newInstance) { var db = new MaterialMeasurementEntities(); try { var importedInventory = db.ImportedInventories.Where(i => i.MaterialID == newInstance.MaterialID && i.ParcelCode == newInstance.ParcelCode); if (importedInventory.Count() == 0) { db.ImportedInventories.Add(newInstance); SaveChanges(db); } } catch (Exception) { return(false); } return(true); }