Пример #1
0
 public static Drive GetDriveById(int id)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         return(db.Drives.FirstOrDefault(u => u.driveCode.Equals(id)));
     }
 }
Пример #2
0
 public static User GetUserById(string id)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         return db.User.FirstOrDefault(u => u.userCode.Equals(id));
     }
 }
Пример #3
0
 public static Package GetPackageById(int id)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         return(db.Packages.FirstOrDefault(u => u.packageCode.Equals(id)));
     }
 }
Пример #4
0
 public static Loction GetLocationById(int id)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         return(db.Loctions.FirstOrDefault(l => l.locationId.Equals(id)));
     }
 }
Пример #5
0
 public static List <Drive> GetSpesificDrives(DateTime date, TimeSpan time)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         var q = db.Drives.Where(d => d.travelDate >= date).ToList();
         return(q);
     }
 }
Пример #6
0
 public static List <Drive> GetAllDrives()
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         var q = db.Drives.ToList();
         return(q);
     }
 }
Пример #7
0
 public static List <Package> GetAllPackages()
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         var q = db.Packages.ToList();
         return(q);
     }
 }
Пример #8
0
 public static List<User> GetAllUsers()
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         var q = db.User.ToList();
         return q;
     }
 }
Пример #9
0
        public static string AddUser(User user)
        {
            using (DBDeliveries1Entities db = new DBDeliveries1Entities())
            {
                db.User.Add(user);
                db.SaveChanges();
                if(GetUserById(user.userCode) !=null)
                return "add delivery";
                return "not add";
            }

        }
Пример #10
0
 public static string AddDrive(Drive drive)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         db.Drives.Add(drive);
         db.SaveChanges();
         if (GetDriveById(drive.driveCode) != null)
         {
             return("add drive");
         }
         return("not added drive");
     }
 }
Пример #11
0
 public static string AddPackage(Package package)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         db.Packages.Add(package);
         db.SaveChanges();
         if (GetPackageById(package.packageCode) != null)
         {
             return("add delivery");
         }
         return("not add");
     }
 }
Пример #12
0
        public static Loction AddLocation(Loction l)
        {
            try
            {
                using (DBDeliveries1Entities db = new DBDeliveries1Entities())
                {
                    Loction lo = db.Loctions.FirstOrDefault(u => u.locationLat == l.locationLat && u.locationLng == l.locationLng && u.locationFormat == l.locationFormat);
                    if (lo == null)
                    {
                        db.Loctions.Add(l);
                        db.SaveChanges();


                        lo = db.Loctions.FirstOrDefault(u => u.locationLat == l.locationLat && u.locationLng == l.locationLng && u.locationFormat == l.locationFormat);
                    }
                    return(lo);
                }
            }
            catch (Exception e)

            {
                return(null);
            }
        }