コード例 #1
0
        //GET : /api/ProjectBoard/GetCurrentProjects
        public Object GetCurrentDevelopers(int id)
        {
            List <DeveloperListModel> developerList = new List <DeveloperListModel>();
            int findId = id;

            if (id == 0)
            {
                findId = _context.Projects.FirstOrDefault().Id;
            }
            var currPrj = _context.Projects.Include(p => p.ProjectDevelopers).ThenInclude(d => d.Developer).FirstOrDefault(pr => pr.Id == findId);

            if (currPrj == null)
            {
                return(BadRequest(new { message = "No project in database." }));
            }
            var devList = currPrj.ProjectDevelopers.ToList();

            foreach (ProjectDeveloper developer in devList)
            {
                DeveloperListModel addDeveloper = new DeveloperListModel {
                    Id = developer.Developer.Id, Name = developer.Developer.Name
                };
                developerList.Add(addDeveloper);
            }
            return(developerList);
        }
コード例 #2
0
        //GET : /api/ProjectBoard/GetDevelopers
        public List <DeveloperListModel> GetDevelopers()
        {
            List <DeveloperListModel> developerList = new List <DeveloperListModel>();

            foreach (Developer developer in _context.Developers)
            {
                DeveloperListModel addDeveloper = new DeveloperListModel {
                    Id = developer.Id, Name = developer.Name
                };
                developerList.Add(addDeveloper);
            }
            return(developerList);
        }