コード例 #1
0
        public async Task <IReadOnlyCollection <ProjectDTO> > ReadDetailedAsync()
        {
            var projects = from p in _context.Projects
                           select new ProjectDTO
            {
                Id          = p.Id,
                Title       = p.Title,
                Description = p.Description,
                Location    = (p.Location == null) ? null : new LocationDTO()
                {
                    Id = p.Location.Id, City = p.Location.City, Country = p.Location.Country
                },
                Skills      = EntityConversionHelper.ConvertSkillsToSkillDTOs(p.Skills),
                Sparks      = EntityConversionHelper.ConvertSparksToSparkDTOs(p.Sparks),
                CreatedDate = p.CreatedDate,
                Category    = (p.Category == null) ? null : new CategoryDTO()
                {
                    Id = p.Category.Id, Name = p.Category.Name
                },
                Creator = (p.Creator == null) ? null : new UserDTO()
                {
                    Id = p.Creator.Id, Firstname = p.Creator.Firstname, Location = (p.Creator.Location == null) ? null : new LocationDTO()
                    {
                        Id = p.Creator.Location.Id, City = p.Creator.Location.City, Country = p.Location.Country
                    }, Mail = p.Creator.Mail, Skills = EntityConversionHelper.ConvertSkillsToSkillDTOs(p.Creator.Skills), Surname = p.Creator.Surname
                }
            };

            return(await projects.ToListAsync());
        }
コード例 #2
0
        public async Task <IReadOnlyCollection <UserDTO> > ReadAsync()
        {
            var users = from u in _context.Users
                        select new UserDTO
            {
                Id        = u.Id,
                Firstname = u.Firstname,
                Surname   = u.Surname,
                Mail      = u.Mail,
                Location  = (u.Location == null) ? null : new LocationDTO()
                {
                    Id = u.Location.Id, City = u.Location.City, Country = u.Location.Country
                },
                Skills = EntityConversionHelper.ConvertSkillsToSkillDTOs(u.Skills)
            };

            return(await users.ToListAsync());
        }
コード例 #3
0
        public async Task <UserDTO> FindFromAzureUIdAsync(string azureUId)
        {
            var user = await _context.Users.AsNoTracking().Where(u => u.AzureUId == azureUId).FirstOrDefaultAsync();

            if (user is null)
            {
                return(null);
            }

            return(new UserDTO
            {
                Id = user.Id,
                Firstname = user.Firstname,
                Surname = user.Surname,
                Mail = user.Mail,
                Location = (user.Location == null) ? null : new LocationDTO()
                {
                    Id = user.Location.Id, City = user.Location.City, Country = user.Location.Country
                },
                Skills = EntityConversionHelper.ConvertSkillsToSkillDTOs(user.Skills)
            });
        }
コード例 #4
0
        public async Task <ProjectDTO> FindAsync(int projectId)
        {
            var project = await _context.Projects.FindAsync(projectId);

            if (project is null)
            {
                return(null);
            }
            else
            {
                return new ProjectDTO
                       {
                           Id          = project.Id,
                           Title       = project.Title,
                           Description = project.Description,
                           Location    = (project.Location is null) ? null : new LocationDTO()
                           {
                               Id = project.Location.Id, City = project.Location.City, Country = project.Location.Country
                           },
                           Skills   = EntityConversionHelper.ConvertSkillsToSkillDTOs(project.Skills),
                           Sparks   = EntityConversionHelper.ConvertSparksToSparkDTOs(project.Sparks),
                           Category = (project.Category is null) ? null : new CategoryDTO()
                           {
                               Id = project.Category.Id, Name = project.Category.Name
                           },
                           CreatedDate = project.CreatedDate,
                           Creator     = (project.Creator == null) ? null : new UserDTO()
                           {
                               Id = project.Creator.Id, Firstname = project.Creator.Firstname, Location = (project.Creator.Location == null) ? null : new LocationDTO()
                               {
                                   Id = project.Creator.Location.Id, City = project.Creator.Location.City, Country = project.Location.Country
                               }, Mail = project.Creator.Mail, Skills = EntityConversionHelper.ConvertSkillsToSkillDTOs(project.Creator.Skills), Surname = project.Creator.Surname
                           }
                       }
            };
        }