示例#1
0
        public BulkViewModel Get()
        {
            var ageLimit = TimeSpan.FromDays(31 * 3);

            var result = new BulkViewModel
            {
            };

            foreach (var context in _contextManager.Servers)
            {
                if (context.Players == null)
                {
                    continue;
                }

                var players = new List <PlayerServerViewModel>();

                foreach (var player in context.Players)
                {
                    if (DateTime.UtcNow - player.SavedAt > ageLimit)
                    {
                        continue;
                    }

                    var vm = PlayerController.BuildViewModelForPlayer(context, player);

                    players.Add(vm);
                }

                result.Servers.Add(context.Config.Key, players);
                result.MapNames.Add(context.Config.Key, context.SaveState?.MapName);
            }

            return(result);
        }
示例#2
0
        public ActionResult AddDrivePapersList(BulkViewModel model)
        {
            var examPapers = (List <dynamic>)Session["ICASPapers"];

            if (examPapers != null && examPapers.Count > 0)
            {
                try
                {
                    var createExamsListResponse = HttpDataProvider.PostAndReturn <List <dynamic>, List <int> >("exam/createlist", examPapers);
                    Session.Remove("ICASPapers");
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    // Todo: error handling
                }
            }
            // Todo: Error handling

            return(View("Index", model));
        }
示例#3
0
        public async Task <ActionResult> Index(CancellationToken cancellationToken)
        {
            var result = await new AuthorizationCodeMvcApp(this, new AppFlowMetadata()).AuthorizeAsync(cancellationToken);

            if (result.Credential != null)
            {
                var service = new DriveService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = result.Credential,
                    ApplicationName       = ApplicationName
                });

                try
                {
                    var bulkViewModel = new BulkViewModel();

                    FilesResource.ListRequest request = service.Files.List();
                    request.Q = "mimeType = 'application/vnd.google-apps.folder'";

                    var fileList = await request.ExecuteAsync();

                    Session["GoogleDriveFolders"] = fileList;

                    bulkViewModel.Folders  = getDriveFoldersList(fileList);
                    bulkViewModel.Grades   = getGradesList();
                    bulkViewModel.Subjects = getSubjectsList();

                    return(View(bulkViewModel));
                }
                catch (Exception ex)
                {
                    // Todo: Log errors and show friendly error
                    throw ex;
                }
            }
            else
            {
                return(new RedirectResult(result.RedirectUri));
            }
        }