Beispiel #1
0
 public static List<Project> GetAllProjectsForUser(User user)
 {
     // Gets all projects currently on the filesystem.
     List<Project> allProjects = Storage.GetAllProjects();
     List<Project> projectsToReturn = new List<Project>();
     // Adds the projecs the user either owns or that are shared with him.
     foreach (Project p in allProjects)
     {
         if (String.Compare(p.Owner.ToString().ToLower(), user.ToString().ToLower()) == 0)
             projectsToReturn.Add(p);
         else
         {
             foreach (User u in p.SharedWith)
             {
                 if (String.Compare(u.ToString().ToLower(), user.ToString().ToLower()) == 0)
                     projectsToReturn.Add(p);
             }
         }
     }
     return projectsToReturn;
 }
        public List<Project> GetAllProjectsOnServer(User user)
        {
            Console.WriteLine("{0} wants to see his projects", user);
            List<Project> projects = Storage.GetAllProjects();
            List<Project> UserProjects = new List<Project>();
            foreach(Project p in projects)
            {
                if (p != null)
                {
                    if (user.ToString().ToLower().CompareTo(p.Owner.ToString().ToLower()) == 0 || p.SharedWith.Contains(user))
                    {
                        UserProjects.Add(p);
                    }
                }

            }
            return UserProjects;
        }
Beispiel #3
0
        /**
         * Called when the window is loaded.
         */
        private void MainWindow_Load(object sender, EventArgs e)
        {
            // Ask for who the user is
            InputDialog inputDialog = new InputDialog("Hello and welcome! Who are you? (Input username)",
                "",
                false);
            inputDialog.ShowDialog();
            activeUser = new User(inputDialog.Input);

            userLabel.Text = "Logged in as: " + activeUser.ToString();

            RefreshTreeView();
        }