コード例 #1
0
        private async Task AddProjectAdmins(Project project, List <DragonflyUser> admins)
        {
            foreach (var admin in admins)
            {
                var existingStage =
                    await _projectAdminRepository
                    .FindByCondition(x =>
                                     x.Admin.UserName == admin.UserName && x.ProjectId == project.Id)
                    .SingleOrDefaultAsync().ConfigureAwait(false);

                if (existingStage != null)
                {
                    continue;
                }
                var _admin = await _userManager.FindByNameAsync(admin.UserName).ConfigureAwait(false);

                if (_admin == null)
                {
                    continue;
                }

                await _projectAdminRepository.CreateAsync(new ProjectAdmin
                                                          { AdminId = _admin.Id, ProjectId = project.Id }).ConfigureAwait(false);
            }
            await _projectAdminRepository.SaveAsync().ConfigureAwait(false);
        }
コード例 #2
0
        public async Task <(List <DragonflyUser> list, int count)> GetAllProjectAdminsAsync(Guid projectId, PaginationFilter paginationFilter = null)
        {
            var queryable = _projectAdminRepository.FindByCondition(pa => pa.ProjectId == projectId).Include(pa => pa.Admin).Select(pa => pa.Admin);

            List <DragonflyUser> admins;
            var count = await queryable.CountAsync().ConfigureAwait(false);

            if (paginationFilter == null)
            {
                admins = await queryable
                         .ToListAsync()
                         .ConfigureAwait(false);
            }
            else
            {
                var skip = (paginationFilter.PageNumber - 1) * paginationFilter.PageSize;
                admins = await queryable
                         .Skip(skip)
                         .Take(paginationFilter.PageSize)
                         .ToListAsync()
                         .ConfigureAwait(false);
            }
            return(list : admins, count);
        }