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 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 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);
        }
Пример #4
0
 public static void Log(DSModel db, LogType type, string location, string message)
 {
     DriverSolutions.DAL.Log log = new Log();
     try
     {
         log.LogType = (byte)type;
         log.LogLocation = location;
         log.LogMessage = message;
         db.Add(log);
         db.FlushChanges();
     }
     catch (Exception ex)
     {
         try
         {
             File.AppendAllText("error.log", log.ToMessage());
         }
         catch { }
     }
 }
Пример #5
0
 public static void Log(DSModel db, LogType type, string location, string message)
 {
     DriverSolutions.DAL.Log log = new Log();
     try
     {
         log.LogType     = (byte)type;
         log.LogLocation = location;
         log.LogMessage  = message;
         db.Add(log);
         db.FlushChanges();
     }
     catch (Exception ex)
     {
         try
         {
             File.AppendAllText("error.log", log.ToMessage());
         }
         catch { }
     }
 }
Пример #6
0
 public static void Log(DSModel db, Exception ex, string location = "")
 {
     Logger.Log(db, LogType.Error, (location == "" ? "Error" : location), ex.ToString());
     db.FlushChanges();
 }
        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
                    });
            }
        }
        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);
        }
Пример #9
0
 public static void Log(DSModel db, Exception ex, string location = "")
 {
     Logger.Log(db, LogType.Error, (location == "" ? "Error" : location), ex.ToString());
     db.FlushChanges();
 }