Exemplo n.º 1
0
        }         // End of DropTask

        /*
         * @param user - the user that wants to adopt the projectsuggestion
         * @param projectSuggestion - the one that will be adopted? adoptend? ...
         * @return ProjecData - after creating the project and database and whatevs
         */
        public ProjectData AdoptProjectSuggestion(UserData user, 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.º 2
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