Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public async Task <bool> CreateProjectAdminAsync(ProjectAdmin projectAdmin)
        {
            if (projectAdmin == null)
            {
                return(false);
            }

            await _projectAdminRepository.CreateAsync(projectAdmin).ConfigureAwait(false);

            var created = await _projectAdminRepository.SaveAsync().ConfigureAwait(false);

            return(created > 0);
        }