コード例 #1
0
 public List <User> getUsers()
 {
     using (db = new TorrentDBContext())
     {
         return(db.Users.ToList());
     }
 }
コード例 #2
0
 public void addUser(User other)
 {
     using (db = new TorrentDBContext())
     {
         db.Users.InsertOnSubmit(other);
         db.SubmitChanges();
     }
 }
コード例 #3
0
 public void addFile(File other)
 {
     using (db = new TorrentDBContext())
     {
         db.Files.InsertOnSubmit(other);
         db.SubmitChanges();
     }
 }
コード例 #4
0
 public void deleteAllFiles()
 {
     using (db = new TorrentDBContext())
     {
         foreach (var file in db.Files)
         {
             db.Files.DeleteOnSubmit(file);
         }
         db.SubmitChanges();
     }
 }
コード例 #5
0
 public bool isValid(User other)
 {
     using (db = new TorrentDBContext())
     {
         foreach (var user in db.Users)
         {
             if (user.name.Equals(other.name) && user.password.Equals(other.password))
             {
                 return(true);
             }
         }
         return(false);
     }
 }
コード例 #6
0
 public void logout(User other)
 {
     using (db = new TorrentDBContext())
     {
         foreach (var user in db.Users)
         {
             if (user.name.Equals(other.name))
             {
                 user.isAvailable = false;
                 db.SubmitChanges();
             }
         }
     }
 }
コード例 #7
0
 public bool contain(User other)
 {
     using (db = new TorrentDBContext())
     {
         foreach (var user in db.Users)
         {
             if (user.name.Equals(other.name))
             {
                 return(true);
             }
         }
         return(false);
     }
 }
コード例 #8
0
 public void disable(string name)
 {
     using (db = new TorrentDBContext())
     {
         foreach (var user in db.Users)
         {
             if (user.name == name)
             {
                 user.isAvailable = false;
             }
         }
         db.SubmitChanges();
     }
 }
コード例 #9
0
 public void removeUser(User other)
 {
     using (db = new TorrentDBContext())
     {
         foreach (var user in db.Users)
         {
             if (user.name.Equals(other.name))
             {
                 db.Users.DeleteOnSubmit(user);
                 db.SubmitChanges();
             }
         }
     }
 }
コード例 #10
0
 public bool contain(string name)
 {
     using (db = new TorrentDBContext())
     {
         foreach (var file in db.Files)
         {
             if (file.name.Equals(name))
             {
                 return(true);
             }
         }
         return(false);
     }
 }
コード例 #11
0
 public void removeFile(File other, string userName)
 {
     using (db = new TorrentDBContext())
     {
         foreach (var file in db.Files)
         {
             if (file.name.Equals(other.name) && file.allUsers.Equals(userName))
             {
                 db.Files.DeleteOnSubmit(file);
                 db.SubmitChanges();
             }
         }
     }
 }
コード例 #12
0
 public bool contain(User otherUser, File otherFile)
 {
     // Check if the user already got the file under his name.
     using (db = new TorrentDBContext())
     {
         foreach (var file in db.Files)
         {
             if (file.name == otherFile.name && file.allUsers.Equals(otherFile.allUsers))
             {
                 return(true);
             }
         }
         return(false);
     }
 }
コード例 #13
0
        public List <User> getActiveUsers()
        {
            List <User> list = new List <User>();

            using (db = new TorrentDBContext())
            {
                foreach (var user in db.Users)
                {
                    if (user.isAvailable == true)
                    {
                        list.Add(user);
                    }
                }
            }
            return(list);
        }
コード例 #14
0
 public List <File> getFiles()
 {
     using (db = new TorrentDBContext())
     {
         List <File> list = new List <File>();
         foreach (var file in db.Files)
         {
             foreach (var user in db.Users)
             {
                 if (user.isAvailable == true && !list.Contains(file))
                 {
                     list.Add(file);
                 }
             }
         }
         return(db.Files.ToList());
     }
 }
コード例 #15
0
 public List <User> getFileUsersList(string fileName)
 {
     using (db = new TorrentDBContext())
     {
         List <User> list = new List <User>();
         foreach (var file in db.Files)
         {
             if (file.name.Equals(fileName))
             {
                 foreach (var user in db.Users)
                 {
                     if (user.name.Equals(file.allUsers) && user.isAvailable == true)
                     {
                         list.Add(user);
                     }
                 }
             }
         }
         return(list);
     }
 }