Exemplo n.º 1
0
        } // End of GetActiveProjectsList()

        //H
        public List <ProjectSuggestionData> GetProjectSuggestionsList()
        {
            try
            {
                List <ProjectSuggestionData> returnList = new List <ProjectSuggestionData>();

                OpenConnection();
                string query = "SELECT * FROM projectsuggestions";//" WHERE TerminatedBy = " + DBDefaults.DefaultId + ";";

                MySqlDataAdapter dataAdapter = new MySqlDataAdapter(query, connection);
                DataSet          ds          = new DataSet();
                dataAdapter.Fill(ds, "projectsuggestions");
                CloseConnection();

                if (ds.Tables["projectsuggestions"].Rows.Count == 0)
                {
                    return(null);
                }

                foreach (DataRow row in ds.Tables["projectsuggestions"].Rows)
                {
                    ProjectSuggestionData projectSuggestionData = new ProjectSuggestionData();
                    projectSuggestionData.FillFromDataRow(row);
                    returnList.Add(projectSuggestionData);
                }

                return(returnList);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(null);
            }
        }
Exemplo n.º 2
0
        } // End of DropTask

        /*
         * @param projectSuggestion - the one that will be adopted? adoptend? ...
         * @return ProjecData - after creating the project and database and whatevs
         */
        public ProjectData AdoptProjectSuggestion(ProjectSuggestionData projectSuggestion)
        {
            try
            {
                // Check if user has active task
                this.RefreshUser(user);
                if (user.ActiveProject != DBDefaults.DefaultId)
                {
                    return(null);
                }

                // Fetch the data from the projectSuggestion and put it into the new project
                ProjectData newProject = new ProjectData(user.ID);
                newProject.Title               = projectSuggestion.Title;
                newProject.ShortDescription    = projectSuggestion.ShortDescription;
                newProject.DetailedDescription = projectSuggestion.DetailedDescription;
                newProject.CreatedBy           = projectSuggestion.CreatedBy;
                newProject.ProjectLead         = user.ID;
                newProject.DateCreated         = DateTime.Now;
                newProject.Notes               = projectSuggestion.Notes;
                this.InsertNewProject(newProject);

                // HACK I know, I know, It was the deadline's fault!
                List <ProjectData> listOfAllProjects = this.GetActiveProjectsList();
                foreach (ProjectData p in listOfAllProjects)
                {
                    if (p.ProjectLead == newProject.ProjectLead)
                    {
                        newProject = new ProjectData(p); // Rebuild with variables from p (for ID reasons)
                        break;
                    }
                }

                // Add active task to user
                user.ActiveProject = newProject.ID;
                this.UpdateUser(user);

                // Delete SuggestedProject
                this.RemoveProjectSuggestion(projectSuggestion);
                projectSuggestion = null;

                return(newProject);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(null);
            }
        } // End of AdoptProjectSuggestions ()
Exemplo n.º 3
0
        } // End of RemoveTask

        /*
         * @param pj - that projectSuggestion that will be deleted
         */
        public bool RemoveProjectSuggestion(ProjectSuggestionData pj)
        {
            try
            {
                OpenConnection();
                string       query   = "DELETE FROM projectSuggestions WHERE  Id = " + pj.ID + ";";
                MySqlCommand command = new MySqlCommand(query, connection);

                command.ExecuteNonQuery();
                command.Dispose();
                CloseConnection();
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
            }
        } // End of RemoveTask