public Driver AddDriver(Driver driver)
 {
     using (DriverEtaContext context = new DriverEtaContext())
     {
         context.Configuration.ProxyCreationEnabled = false;
         context.Drivers.Add(driver);
         context.SaveChanges();
     }
     return(driver);
 }
        public List <Driver> GetAllDrivers()
        {
            List <Driver> lstDrivers = new List <Driver>();

            using (DriverEtaContext context = new DriverEtaContext())
            {
                context.Configuration.ProxyCreationEnabled = false;
                lstDrivers = context.Drivers.ToList <Driver>();
            }
            return(lstDrivers);
        }
        public Driver GetDriverID(string id)
        {
            int ID = Convert.ToInt16(id);

            using (DriverEtaContext context = new DriverEtaContext())
            {
                context.Configuration.ProxyCreationEnabled = false;
                var temp = context.Drivers
                           .Select(t => new { t.DOB, t.DriverID, t.FirstName, t.LastName })
                           .Where(i => i.DriverID == ID)
                           .ToList();

                return(temp
                       .Select(t => new Driver {
                    DOB = t.DOB.Value, DriverID = t.DriverID, FirstName = t.FirstName.Trim(), LastName = t.LastName.Trim()
                })
                       .SingleOrDefault());
            }
        }