コード例 #1
0
        public IActionResult GetTask(int id)
        {
            IActionResult result;
            Jalon         Jalon = JalonRepository.GetById(id);

            if (Jalon == null)
            {
                result = NotFound(new { Message = "Project inexistant ou vous n'avez pas le droit d'y accéder!" });
            }
            else
            {
                Project Project = ProjectRepository.GetById(Jalon.ProjectId);
                //on vérifie que l'utilisateur peut effectuvé l'action

                if (!this.Access(Project.Id))
                {
                    result = Unauthorized(new { Message = "Project inexistant ou vous n'avez pas le droit d'y accéder!" });
                }
                else
                {
                    result = Ok(this.TaskRepository.GetTaskForJalon(id));
                }
            }


            return(result);
        }
コード例 #2
0
        public IActionResult Get(int id)
        {
            IActionResult result;
            Jalon         Jalon = JalonRepository.GetById(id);

            if (Jalon != null)
            {
                Project Project = ProjectRepository.GetById(Jalon.ProjectId);
                //on vérifie que l'utilisateur n'est pas un chef et que le projet lui est bien assigné avant de lui transmettre l'exigence
                if (!this.Access(Project.Id))
                {
                    result = NotFound(new { Message = "Vous n'avez pas le droit d'accéder à la ressource demander!" });
                }
                else
                {
                    result = Ok(Jalon);
                }
            }
            else
            {
                result = NotFound(new { Message = "Exigence inexistante!" });
            }


            return(result);
        }
コード例 #3
0
 public AbstractController(ILogger <Controller> logger, DbConfig context)
 {
     _logger            = logger;
     _context           = context;
     ProjectRepository  = new ProjectRepository(_context);
     ExigenceRepository = new ExigenceRepository(_context);
     JalonRepository    = new JalonRepository(_context);
     TaskRepository     = new TaskRepository(_context);
 }
コード例 #4
0
        private int GetProjectId(int idJalon)
        {
            Jalon Jalon  = JalonRepository.GetById(idJalon);
            int   result = 0;

            if (Jalon != null)
            {
                Project Project = ProjectRepository.GetById(Jalon.ProjectId);
                if (Project != null)
                {
                    result = Project.Id;
                    ProjectRepository.Detach(Project);
                }
            }
            JalonRepository.Detach(Jalon);

            return(result);
        }