public HomeController()
 {
     context            = new ApplicationDbContext();
     patientRepository  = new PatientRepository(context);
     exerciseRepository = new ExerciseRepository(context);
     graphRepository    = new GraphRepository(context);
 }
        public async Task <ActionResult> Auth()
        {
            var authHelper = new AuthHelper();
            var appState   = new AppState();

            // get id token from successful AzureAD auth
            var openIdToken = AuthHelper.OpenIdToken(Request.Form["id_token"]);

            appState.TenantId     = openIdToken.TenantId;
            appState.TenantDomain = openIdToken.Domain;
            appState.LoggedOnUser = openIdToken.UserPrincipalName;

            // set app as authoirzed
            appState.AppIsAuthorized = true;

            // obtain access token for graph client
            var appOnlyGraphToken = await authHelper.GetAppOnlyAccessToken(SettingsHelper.GraphResourceId);

            appState.AppOnlyGraphToken = appOnlyGraphToken;

            // TODO LATER: get all users in the directory
            var graphRepo = new GraphRepository();
            var users     = await graphRepo.GetUsers(appOnlyGraphToken);

            appState.MailboxList = users;

            Session["ClientCredsAddinAppState"] = appState;

            return(new RedirectResult("/Mail"));
        }
        public GraphsViewModel(GraphRepository repository, INavigationService navigationService)
        {
            _repository = repository;
            _navigationService = navigationService;

            Graphs = new BindableCollection<object>();
            CollectionViewSource source = new CollectionViewSource();
        }
Example #4
0
        // GET api/<controller>/5
        public HttpResponseMessage Get(int id)
        {
            GraphRepository repo     = new GraphRepository();
            string          cypher   = string.Format("MATCH (w:World)<-[parent*]-(s:Shape)-[edge*]->(p) where ID(w) = {0} RETURN w,s,p,edge,parent", id);
            var             response = repo.Get(cypher);

            return(Request.CreateResponse(HttpStatusCode.OK, response, "application/json"));
        }
 public SaveToDatabaseViewModel(Graph graph, string degreeSequence)
 {
     _graph           = new Graph();
     _graph           = graph;
     _degreeSequence  = degreeSequence;
     _graphRepository = new GraphRepository();
     SaveCommand      = new RelayCommand(SaveToDatabase, CheckFileName);
 }
 public LoadGraphViewModel(Graph graph)
 {
     LoadGraphCommand = new RelayCommand(LoadGraph, (n) => true);
     _graph           = graph;
     _graphRepository = new GraphRepository();
     FileNameList     = new ObservableCollection <string>();
     _graphRepository.GetFileNames(FileNameList);
     SelectedIndexFileNames = 0;
     ShowGraphProperties();
 }
Example #7
0
        public async Task <IActionResult> Register(DeviceSelectPageViewModel viewModel)
        {
            using (var graph = new GraphRepository(await HttpContext.GetTokenAsync("access_token")))
            {
                var user = await graph.GetUserAsync();

                await UserInfoRepository.RegistDeviceIdAsync(user.Id, viewModel.SelectedDeviceId);
            }

            return(RedirectToAction("Index"));
        }
        public void SetUp()
        {
            _clientFactory    = new Mock <IGremlinClientFactory>();
            _client           = new Mock <IGremlinClient>();
            _resultsTransform = new Mock <IPathResultsTransform>();

            _clientFactory.Setup(_ => _.Client)
            .Returns(_client.Object);

            _repository = new GraphRepository(_clientFactory.Object,
                                              _resultsTransform.Object);
        }
Example #9
0
        public async Task TestGetGrapData()
        {
            string          sessionid       = Guid.NewGuid().ToString();
            var             context         = new UnitTestContext();
            GraphRepository graphRepository = new GraphRepository(context);

            context.GraphSessions.Add(GetTestGraphData(sessionid));
            var controller = new GraphController(graphRepository, _logger);
            var result     = await controller.Get(sessionid) as OkNegotiatedContentResult <List <GraphData> >;

            Assert.IsNotNull(result);
            Assert.AreEqual(sessionid, result.Content[0].SessionID);
        }
Example #10
0
        public async Task TestPostGraphData()
        {
            var             context           = new UnitTestContext();
            GraphRepository graphRepository   = new GraphRepository(context);
            var             controller        = new GraphController(graphRepository, _logger);
            var             controllerContext = Create("Graphfile.txt");

            controller.ControllerContext = controllerContext;

            var result =
                await controller.Post() as CreatedAtRouteNegotiatedContentResult <List <GraphData> >;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.RouteName, "DefaultApi");
            Assert.AreEqual(context.GraphSessions.Local.Count, result.Content.Count);
        }
Example #11
0
        public async Task <IActionResult> Index()
        {
            using (var graph = new GraphRepository(await HttpContext.GetTokenAsync("access_token")))
            {
                var devices = await graph.GetDevicesAsync();

                return(View(new DeviceSelectPageViewModel
                {
                    Devices = devices.Select(x => new SelectListItem
                    {
                        Text = $"{x.Name}({x.Platform})",
                        Value = x.Id,
                    }),
                }));
            }
        }
Example #12
0
        private async Task InvokeAppAsync(string accessToken, string scheme)
        {
            try
            {
                using (var graph = new GraphRepository(accessToken))
                {
                    var user = await graph.GetUserAsync();

                    var targetDeviceId = await UserInfoRepository.GetTargetDeviceIdByUserIdAsync(user.Id);

                    await graph.AddLaunchAppRequestAsync(targetDeviceId, scheme);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }
        public async Task <ActionResult> Auth()
        {
            var authHelper = new AuthHelper();
            var appState   = new AppState();

            // set app as authoirzed
            appState.AppIsAuthorized = true;

            // obtain access token for graph client
            var appOnlyGraphToken = await authHelper.GetAppOnlyAccessToken();

            appState.AppOnlyGraphToken = appOnlyGraphToken;

            // TODO LATER: get all users in the directory
            var graphRepo = new GraphRepository();
            var users     = await graphRepo.GetUsers(appOnlyGraphToken);

            appState.MailboxList = users;

            Session["ClientCredsAddinAppState"] = appState;

            return(new RedirectResult("/Mail"));
        }
        // Constructors
        //
        public MainViewModel(IWindowManager windowManager, IDialogsPresenter dialogsPresenter)
        {
            Document   = new GraphDocument();
            Algorithms = AlgorithmProvider.Instance.Algorithms;

            _repository        = new GraphRepository();
            _cursorModeManager = new CursorModeManager();
            _zoomManager       = new ZoomManager();

            _eventWaiter = new AutoResetEvent(false);

            TableRows = new ObservableCollection <TableRow>();

            WindowManager   = windowManager;
            DialogPresenter = dialogsPresenter;

            MinElementX = 30;
            MinElementY = 30;

            IsNewEdgeEnabled = true;
            NewEdge          = new NewEdge(new Vertex(0, 0), 0, 0);

            Init();
        }
Example #15
0
 public GraphService(GieldaL2TesterContext context)
 {
     _repository = new GraphRepository(context);
 }
        public UserServices()
        {
            UserRepository  repository      = new UserRepository();
            GraphRepository graphRepository = new GraphRepository();

            RedisRepository.RedisRepository redisRepository; = new RedisRepository.RedisRepository();
 public SettingsViewModel(GraphRepository repository)
 {
     _repository = repository;
 }
Example #18
0
 public UserServices()
 {
     repository      = new UserRepository();
     graphRepository = new GraphRepository();
 }
Example #19
0
 public PathManager(IStaticDataRepository staticDataRepository, IGraphRepository graphRepository)
 {
     _staticDataRepository = (StaticDataRepository)staticDataRepository;
     _graphRepository      = (GraphRepository)graphRepository;
 }