Example #1
0
 public static bool DeleteUser(String userId)
 {
     var context = new ShipmentEntities3();
     int userid1 = Convert.ToInt32(userId);
     var query = from user in context.UserTables
                 where user.UserID == userid1
                 select user;
     if (query != null)
     {
         try
         {
             foreach (UserTable user in query)
             {
                 context.UserTables.Remove(user);
             }
                 context.SaveChanges();
             return true;
         }
         catch (Exception e)
         {
             return false;
         }
     }
     return false;
 }
Example #2
0
 public static bool Authenticate(String userID,String password)
 {
     var context = new ShipmentEntities3();
     List<UserTable> userList=context.UserTables.ToList();
     foreach (UserTable user in userList)
     {
         if (user.UserID.Equals(userID) && user.Password.Equals(password))
             return true;
     }
     return false;
 }
Example #3
0
        public static UserTable FindUser(String userid)
        {
            var context = new ShipmentEntities3();
              /*  List<UserTable> userList = context.UserTables.ToList();
            foreach (UserTable user in userList)
            {
                if (user.UserID.Equals(userID))
                    return user;
            }*/
            var query = from user in context.UserTables
                        where user.UserID.ToString() == userid
                        select user;
            UserTable userTable=query.First<UserTable>();

            if (userTable != null)
                return userTable;
            return null;
        }
Example #4
0
 public static bool Authenticate(String userID, String password)
 {
     int userId = 0;
     int.TryParse(userID, out userId);
     var context = new ShipmentEntities3();
     UserTable user = (from u in context.UserTables
                       where u.UserID == userId && u.Password == password
                       select u).FirstOrDefault();
     //foreach (UserTable user in userList)
     //{
     //    if (user.UserID.Equals(userId) && user.Password.Equals(password))
     //        return true;
     //}
     if (user != null)
     {
         return true;
     }
     return false;
 }
Example #5
0
 public static bool InsertUser(String userID, String password, String country, String gender)
 {
     try
     {
         var context = new ShipmentEntities3();
         UserTable user1 = new UserTable();
         user1.UserID = Int32.Parse(userID);
         user1.Password = password;
         user1.Country = country;
         user1.Gender = gender;
         context.UserTables.Add(user1);
         context.SaveChanges();
         context.Dispose();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
Example #6
0
        public static UserTable FindUser(int userid)
        {
            var context = new ShipmentEntities3();
            /*  List<UserTable> userList = context.UserTables.ToList();
              foreach (UserTable user in userList)
              {
                  if (user.UserID.Equals(userID))
                      return user;
              }*/
            var query =(from user in context.UserTables
                        where userid==user.UserID
                        select user);

            foreach (UserTable user in query)
            {
                if (user!= null)
                    return user;
            }
            return null;
        }
Example #7
0
 public static bool DeleteUser(String userId)
 {
     var context = new ShipmentEntities3();
     var query = from user in context.UserTables
                 where user.UserID.ToString() == userId
                 select user;
     if (query != null)
     {
         try
         {
             context.UserTables.Remove((UserTable)query);
             context.SaveChanges();
             return true;
         }
         catch (Exception e)
         {
             return false;
         }
     }
     return false;
 }
Example #8
0
 public static bool UpdateUser(UserTable userTable)
 {
     var context = new ShipmentEntities3();
     var query = from user in context.UserTables
                 where user.UserID == userTable.UserID
                 select user;
     foreach (UserTable user in query)
     {
         user.Password = userTable.Password;
         user.Country = userTable.Country;
         user.Gender = userTable.Gender;
     }
     try
     {
         context.SaveChanges();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }