Example #1
0
 public HubControllerService(IDbService <Infrastructure.Entities.Db.Hub> hubDbService, IDbService <Campus> campusDbService, IGraphGroupService graphGroupService, IGraphUserService graphUserService)
 {
     _hubDbService      = hubDbService;
     _campusDbService   = campusDbService;
     _graphGroupService = graphGroupService;
     _graphUserService  = graphUserService;
 }
Example #2
0
 public GraphUserService(IGraphBaseService graphService, IGraphGroupService graphGroupService,
                         IAppInsightsService appInsightsService, AuthorizationConfiguration authorizationConfiguration)
 {
     _graphService               = graphService;
     _appInsightsService         = appInsightsService;
     _graphGroupService          = graphGroupService;
     _authorizationConfiguration = authorizationConfiguration;
 }
Example #3
0
 public CampusControllerService(IGraphUserService graphUserService, IDbService <Infrastructure.Entities.Db.Campus> campusDbService, IDbService <Hub> hubDbService, AuthorizationConfiguration authorizationConfiguration, IGraphGroupService graphGroupService)
 {
     _graphUserService           = graphUserService;
     _campusDbService            = campusDbService;
     _hubDbService               = hubDbService;
     _authorizationConfiguration = authorizationConfiguration;
     _graphGroupService          = graphGroupService;
 }
        private static void SeedProdData(MccContext context, IGraphGroupService graphService)
        {
            var defaultRemoteHubId = Guid.Parse("00a7df8e-a810-4aa1-9791-6e0a79a911d3");

            // get all campus
            var allGroups = graphService.GetAllGroups().Result.ToList();

            // divide between hubs and campus
            var campusList = allGroups.Where(g => g.Name.StartsWith("Campus "));
            var hubs       = allGroups.Where(g => g.Name.StartsWith("Hub "));

            var dbHubs = hubs.Select(hub => new Hub()
            {
                AadGroupId = hub.Id,
                Campus     = new List <Campus>(),
                CreatedAt  = DateTime.UtcNow,
                Lead       = Guid.Empty,
                ModifiedAt = DateTime.UtcNow,
                Name       = hub.Name
            })
                         .ToList();

            foreach (var campus in campusList)
            {
                // check if campus exists, otherwise add it
                if (context.Campus.Any(c => c.AadGroupId == campus.Id))
                {
                    continue;
                }

                // find hub for campus
                if (!Guid.TryParse(campus.Description, out var hubId))
                {
                    // description could not be parsed as a guid -> take the default hub Id
                    hubId = defaultRemoteHubId;
                }

                var hub       = dbHubs.FirstOrDefault(h => h.AadGroupId == hubId);
                var newCampus = new Campus(campus.Name, Guid.Empty, campus.Id, campus.Name.Replace("Campus ", ""),
                                           Guid.Empty)
                {
                    Hub        = hub,
                    AadGroupId = campus.Id
                };
                // this will also add the campus to the corrsponding hub
                context.Campus.Add(newCampus);
            }

            var newHubs = dbHubs.Where(h => !context.Hubs.Any(hDb => hDb.AadGroupId == h.AadGroupId));

            context.Hubs.AddRange(newHubs);
            context.SaveChanges();
        }
 public GroupMembershipPolicyHandler(IGraphGroupService graphService)
 {
     _graphService = graphService;
 }