Exemplo n.º 1
0
 public static Drive GetDriveById(int id)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         return(db.Drives.FirstOrDefault(u => u.driveCode.Equals(id)));
     }
 }
Exemplo n.º 2
0
 public static User GetUserById(string id)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         return db.User.FirstOrDefault(u => u.userCode.Equals(id));
     }
 }
Exemplo n.º 3
0
 public static Package GetPackageById(int id)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         return(db.Packages.FirstOrDefault(u => u.packageCode.Equals(id)));
     }
 }
Exemplo n.º 4
0
 public static Loction GetLocationById(int id)
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         return(db.Loctions.FirstOrDefault(l => l.locationId.Equals(id)));
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 6
0
 public static List <Drive> GetAllDrives()
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         var q = db.Drives.ToList();
         return(q);
     }
 }
Exemplo n.º 7
0
 public static List <Package> GetAllPackages()
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         var q = db.Packages.ToList();
         return(q);
     }
 }
Exemplo n.º 8
0
 public static List<User> GetAllUsers()
 {
     using (DBDeliveries1Entities db = new DBDeliveries1Entities())
     {
         var q = db.User.ToList();
         return q;
     }
 }
Exemplo n.º 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";
            }

        }
Exemplo n.º 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");
     }
 }
Exemplo n.º 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");
     }
 }
Exemplo n.º 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);
            }
        }