示例#1
0
        protected bool Access(int idProject)
        {
            Project Project = ProjectRepository.GetById(idProject);
            int     userId  = this.GetId();
            bool    result  = true;

            if (Project == null)
            {
                result = false;
            }
            else
            {
                if (Project.Id != userId && !this.IsChief())
                {
                    Jalon Jalon = JalonRepository.getForUser(idProject, userId);
                    if (Jalon == null)
                    {
                        bool         trouver = false;
                        List <Jalon> Jalons  = JalonRepository.GetJalonForProject(idProject);
                        foreach (Jalon aJalon in Jalons)
                        {
                            Task task = TaskRepository.getTaskForUser(aJalon.Id, userId);
                            if (task != null)
                            {
                                trouver = true;
                            }

                            TaskRepository.Detach(task);
                            JalonRepository.Detach(aJalon);
                        }

                        if (!trouver)
                        {
                            result = false;
                        }
                    }
                }

                ProjectRepository.Detach(Project);
            }

            return(result);
        }