////////////// All DriverTractorHistories will be moved to Driver ///////////////////

        // this method will Add new driverTractorHistory to driverHistories Table
        public DriverTractorAssignmentHistory AddHistory(Employee employee, Tractor tractor)
        {
            DriverTractorAssignmentHistory history = new DriverTractorAssignmentHistory(employee, tractor);

            context.DriverTractorsAssignmentHistory.Add(history);
            context.SaveChanges();
            return(history);
        }
        public DriverTractorHistoryViewModel(Employee driver, Tractor tractor, DriverTractorAssignmentHistory driverTractorAssignmentHistory)
        {
            FirstName  = driver.FirstName;
            MiddleName = driver.MiddleName;
            LastName   = driver.LastName;

            EmployeeId = driver.EmployeeID;
            TractorId  = tractor.TractorID;

            TractorNumber = tractor.TruckNumber;
        }
        // this method will Add new driverTractorHistories
        public void CompleteHistory(Employee employee, Tractor tractor)
        {
            DriverTractorAssignmentHistory history = context.DriverTractorsAssignmentHistory.Where(dt => dt.DateTimeUnassigned == null).Where(trac => trac.TractorId == tractor.TractorID).Where(emp => emp.EmployeeId == employee.EmployeeID).Single();

            if (history != null)
            {
                DateTime dateTime = DateTime.Now;
                history.DateTimeUnassigned = dateTime;
            }
            context.SaveChanges();
        }
        // this method will Remove a particular driverTractorHistory
        public bool RemoveHistory(Employee employee, Tractor tractor)
        {
            DriverTractorAssignmentHistory history = context.DriverTractorsAssignmentHistory.Where(dt => dt.DateTimeUnassigned == null).Where(trac => trac.TractorId == tractor.TractorID).Single();

            if (history != null)
            {
                //System.Diagnostics.Debug.WriteLine(employee.EmployeeID);
                context.DriverTractorsAssignmentHistory.Remove(history);
                context.SaveChanges();
                return(true);
            }
            return(false);
        }