private static void InsertMedical(DSModel db, KeyBinder key, DriverMedicalModel model) { DriversMedical poco = new DriversMedical(); model.Map(poco); db.Add(poco); key.AddKey(poco, model, model.GetName(p => p.DriverMedicalID)); db.FlushChanges(); SaveReminders(db, key, model, poco); }
private static void UpdateMedical(DSModel db, KeyBinder key, DriverMedicalModel model) { var poco = db.DriversMedicals .Where(m => m.DriverMedicalID == model.DriverMedicalID) .FirstOrDefault(); model.Map(poco); db.FlushChanges(); SaveReminders(db, key, model, poco); }
private static void InsertDriverLicense(DSModel db, KeyBinder key, DriverLicenseModel model) { var poco = new DriversLicense(); model.Map(poco); db.Add(poco); key.AddKey(poco, model, model.GetName(p => p.DriverLicenseID)); db.FlushChanges(); SaveDriverLicensePermits(db, key, poco, model); SaveDriverLicenseReminders(db, key, poco, model); }
private static void UpdateDriverLicense(DSModel db, KeyBinder key, DriverLicenseModel model) { var poco = db.DriversLicenses.Where(d => d.DriverLicenseID == model.DriverLicenseID).FirstOrDefault(); if (poco == null) { throw new ArgumentNullException("poco"); } model.Map(poco); db.FlushChanges(); SaveDriverLicensePermits(db, key, poco, model); SaveDriverLicenseReminders(db, key, poco, model); }
private static void UpdateDriver(DSModel db, KeyBinder key, DriverModel model) { var poco = db.Drivers.Where(d => d.DriverID == model.DriverID).FirstOrDefault(); if (poco == null) { throw new ArgumentException("No driver with this ID!"); } poco.DriverCode = model.DriverCode; poco.FirstName = model.FirstName; poco.SecondName = model.SecondName; poco.LastName = model.LastName; poco.DateOfBirth = model.DateOfBirth; poco.DateOfHire = model.DateOfHire; poco.CellPhone = model.CellPhone; poco.EmergencyPhone = model.EmergencyPhone; poco.Email = model.Email; poco.PayRateOverride = model.PayRateOverride; poco.IsEnabled = model.IsEnabled; foreach (var l in poco.LocationsDrivers.ToList()) { db.Delete(l); poco.LocationsDrivers.Remove(l); } db.FlushChanges(); foreach (var l in model.Locations) { poco.LocationsDrivers.Add( new LocationsDriver() { LocationID = l.LocationID, DriverID = l.DriverID, TravelPay = l.TravelPay }); } }