public void AddBatch(Batch Batch) { using (var db = new WeighrContext()) { db.Batches.Add(Batch); db.SaveChanges(); } }
public void UpdateShiftTarget(ShiftTarget shiftTarget) { using (var db = new WeighrContext()) { db.ShiftTargets.Update(shiftTarget); db.SaveChanges(); } }
public void AddShiftTarget(ShiftTarget shiftTarget) { using (var db = new WeighrContext()) { db.ShiftTargets.Add(shiftTarget); db.SaveChanges(); } }
public void UpdateTransactionLog(TransactionLog transactionLog) { using (var db = new WeighrContext()) { db.TransactionLogs.Update(transactionLog); db.SaveChanges(); } }
public void DeleteDeviceInfo() { using (var db = new WeighrContext()) { var dev = db.DeviceInfos.FirstOrDefault(); if (dev != null) { db.DeviceInfos.Remove(dev); db.SaveChanges(); } } }
public ScaleConfig ZeroScale(decimal offset) { using (var db = new WeighrContext()) { var current = db.ScaleConfigs.FirstOrDefault(); // current.offset = offset; db.ScaleConfigs.Update(current); db.SaveChanges(); return(current); } }
public Product SetCurrentProduct(string productCode) { using (var db = new WeighrContext()) { var previousCurrent = db.Products .Where(p => p.isCurrent == true).FirstOrDefault(); if (previousCurrent != null) { previousCurrent.isCurrent = false; db.Products.Update(previousCurrent); } var current = db.Products .Where(p => p.ProductCode == productCode).FirstOrDefault(); current.isCurrent = true; db.Products.Update(current); db.SaveChanges(); return(current); } }