Example #1
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";
            }

        }
Example #2
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");
     }
 }
Example #3
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");
     }
 }
Example #4
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);
            }
        }