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