예제 #1
0
        public ExamsView()
        {
            InitializeComponent();

            ViewModel   = new ExamsViewModel();
            DataContext = ViewModel;
        }
예제 #2
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     Window.Current.SizeChanged -= CurrentWindow_SizeChanged;
     StudentInfoViewModel.Dispose();
     WellknownDataViewModel.Dispose();
     ExamsViewModel.Dispose();
     ScheduleViewModel.Dispose();
 }
예제 #3
0
        public Exams(
            IExamService examService,
            ICourseService courseService,
            IEnrolmentService enrolmentService,
            IStudentExamService studentExamService,
            ISemesterService semesterService,
            IExportService exportService,
            IDownloadFileService downloadFileService)
        {
            viewModel = new ExamsViewModel(examService, courseService, enrolmentService, studentExamService, semesterService, exportService, downloadFileService);

            InitializeComponent();

            this.Loaded += ExamsTable_Load;
        }
예제 #4
0
        public async Task <IActionResult> Index(int value, [Bind("SelectedCity")] ExamsViewModel viewModel)
        {
            var exams = await _repository.Query <Exam>()
                        .Include(exam => exam.City)
                        .ToListAsync();

            List <ExamViewModel> examViewModels = new List <ExamViewModel>();

            exams.ForEach(x => examViewModels.Add(ExamMappings.ToViewModel(x)));
            examViewModels = examViewModels.OrderByDescending(x => x.Date).ToList();

            List <string> AcceptancePeriod = await CalculateAcceptancePeriods(examViewModels);

            var AcceptancePeriods = new List <SelectListItem>();

            foreach (var ap in AcceptancePeriod)
            {
                AcceptancePeriods.Add(new SelectListItem {
                    Value = AcceptancePeriod.FindIndex(a => a == ap).ToString(), Text = ap
                });
            }
            viewModel.AcceptancePeriod = AcceptancePeriods;
            viewModel.ExamViewModels   = examViewModels.Where(x => x.SetAcceptancePeriod == AcceptancePeriods.ElementAt(value).Text).ToList();
            var SelectedAcceptancePeriod = AcceptancePeriods.ElementAt(value);

            viewModel.SelectedAcceptancePeriod   = SelectedAcceptancePeriod.Text;
            TempData["SelectedAcceptancePeriod"] = SelectedAcceptancePeriod.Value;

            var selectedExams = examViewModels.Where(x => x.SetAcceptancePeriod == SelectedAcceptancePeriod.Text).ToList();

            var results = await _repository.Query <Result>().ToListAsync();

            int studentsCountInAcceptancePeriod = 0;

            foreach (var selectedExam in selectedExams)
            {
                int examId = exams.FirstOrDefault(x => x.Date == selectedExam.Date).Id;
                studentsCountInAcceptancePeriod += results.Count(x => x.ExamId == examId);
            }
            TempData["Count"] = studentsCountInAcceptancePeriod;
            _logger.LogInformation("Found {Count} records. User {User}.", viewModel.ExamViewModels.Count(), _user);
            return(View(viewModel));
        }
예제 #5
0
        public override void Execute(object parameter)
        {
            ExamsViewModel examsViewModel = new ExamsViewModel();

            List <ExamModel> examModels = DataProvider.GetExams();

            EnumerationUtil.Enumerate(examModels);

            examsViewModel.AllExams    = examModels;
            examsViewModel.Exams       = new ObservableCollection <ExamModel>(examModels);
            examsViewModel.CurrentExam = new ExamModel();

            ExamsControl examsControl = new ExamsControl();

            examsControl.DataContext = examsViewModel;

            MainWindow mainWindow = (MainWindow)mainViewModel.Window;

            mainWindow.GrdCenter.Children.Clear();
            mainWindow.GrdCenter.Children.Add(examsControl);
        }
예제 #6
0
 public BaseExamCommand(ExamsViewModel viewModel)
 {
     this.viewModel = viewModel;
 }
예제 #7
0
 public SaveExamCommand(ExamsViewModel viewModel) : base(viewModel)
 {
 }
예제 #8
0
 public RejectExamCommand(ExamsViewModel viewModel) : base(viewModel)
 {
 }
 public ExcelExporterExamCommand(ExamsViewModel viewModel) : base(viewModel)
 {
 }
예제 #10
0
 public DeleteExamCommand(ExamsViewModel viewModel) : base(viewModel)
 {
 }
예제 #11
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            Analytics.TrackEvent("Main page reached", new Dictionary <string, string>()
            {
                { "Size", $"{Window.Current.Bounds}" }
            });
            prevWidth = Window.Current.Bounds.Width;
            Window.Current.SizeChanged += CurrentWindow_SizeChanged;

            if (e.Parameter is string argument && !string.IsNullOrEmpty(argument))
            {
                Analytics.TrackEvent("Launched with parameter", new Dictionary <string, string>()
                {
                    { "Parameter", argument }
                });
                if (argument.Equals("ScoreChanged", StringComparison.Ordinal))
                {
                    NavigationView.SelectedItem = NavigationView.MenuItems.Last();
                }
            }

            bool signedIn = Application.Current.GetService <ICredentialService>().IsSignedIn;

            IAsyncOperation <PushNotificationChannel> channelCreationTask = PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
            Task wellknownUpdateTask   = WellknownDataViewModel.StartUpdateAsync(signedIn);
            Task studentInfoUpdateTask = StudentInfoViewModel.StartUpdateAsync(signedIn);

            await wellknownUpdateTask;
            Task  examsUpdateTask    = ExamsViewModel.StartUpdateAsync(signedIn);
            Task  scheduleUpdateTask = ScheduleViewModel.StartUpdateAsync(signedIn);

            if (!signedIn)
            {
                ISignInService signInService = Application.Current.GetService <ISignInService>();
                try
                {
                    await signInService.SignInAsync(false);

                    signedIn = true;
                    Application.Current.GetService <IMessageService <SignInMessage> >().SendMessage(new SignInMessage(true));
                }
                catch (BackendAuthenticationFailedException ex)
                {
                    Crashes.TrackError(ex);
                    Analytics.TrackEvent("Authentication failed");
                    await((App)Application.Current).SignOutAsync();
                }
                catch (BackendRequestFailedException ex)
                {
                    Crashes.TrackError(ex);
                    Application.Current.GetService <IMessageService <SignInMessage> >().SendMessage(new SignInMessage(false));
                }
            }

            if (signedIn)
            {
                INotificationChannelService channelService = Application.Current.GetService <INotificationChannelService>();
                Task channelUpdateTask;
                try
                {
                    PushNotificationChannel channel = await channelCreationTask;
                    channelUpdateTask = channelService.PostNotificationChannelAsync(new NotificationChannelItem(channel.Uri));
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                    channelUpdateTask = Task.CompletedTask;
                }
                await Task.WhenAll(studentInfoUpdateTask, examsUpdateTask, scheduleUpdateTask, channelUpdateTask);
            }
            else
            {
                await Task.WhenAll(studentInfoUpdateTask, examsUpdateTask, scheduleUpdateTask);
            }
        }