public static List <DTO.LicenseDTO> GetLicenses()
        {
            var db         = new TruckerProjectDBEntities();
            var dbLicenses = db.Licenses.ToList();

            return(convertToDTO(dbLicenses));
        }
Example #2
0
        public static List <DTO.TruckerDTO> GetTruckers()
        {
            var db         = new TruckerProjectDBEntities();
            var dbTruckers = db.Truckers.ToList();

            return(convertToDTO(dbTruckers));
        }
Example #3
0
        public static DTO.TruckerDTO EditTrucker(int truckerID)
        {
            var db      = new TruckerProjectDBEntities();
            var trucker = db.Truckers.Where(p => p.TruckerID == truckerID).FirstOrDefault();

            return(convertToDTO(trucker));
        }
Example #4
0
        public static void DeleteTrucker(int truckerID)
        {
            var db      = new TruckerProjectDBEntities();
            var trucker = db.Truckers.Where(p => p.TruckerID == truckerID).FirstOrDefault();

            db.Database.ExecuteSqlCommand("DELETE FROM dbo.LicenseTrucker WHERE TruckerID = {0}", truckerID);
            db.Truckers.Remove(trucker);
            db.SaveChanges();
        }
Example #5
0
        public static void CreateTrucker(TruckerDTO truckerDTO)
        {
            var db = new TruckerProjectDBEntities();

            if (truckerDTO.TruckerID == 0)
            {
                truckerDTO.TruckerID = db.Truckers.Count() == 0 ? 1 : db.Truckers.OrderByDescending(p => p.TruckerID).FirstOrDefault().TruckerID + 1;
            }
            List <License> dbLicenses = db.Licenses.ToList();
            var            dbTrucker  = convertToDb(truckerDTO, dbLicenses);

            db.Truckers.Add(dbTrucker);
            db.SaveChanges();
        }