private async void DownloadQuestionsButton_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (DeviceOpStatus.IsInternetConnected() == true)
            {
                progressIndicator                 = new ProgressIndicator();
                progressIndicator.IsVisible       = true;
                progressIndicator.Text            = "Λήψη Ερωτήσεων. Παρακαλώ περιμένετε...";
                progressIndicator.IsIndeterminate = true;
                SystemTray.SetProgressIndicator(this, progressIndicator);

                try
                {
                    if (await QuestionsService.UpdateQuestions() == true)
                    {
                        MessageBox.Show("Επιτυχής λήψη νέων ερωτήσεων");
                        QuestionsCountText.Text = "Σύνολο ερωτήσεων " + QuestionsService.CountQuestions().ToString();
                    }
                    else
                    {
                        MessageBox.Show("Δεν βρέθηκαν νέες ερωτήσεις");
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Σφάλμα κατα τον συγχρονισμό. Παρακαλώ δοκιμάστε αργότερα");
                }

                progressIndicator.IsVisible       = false;
                progressIndicator.IsIndeterminate = false;
            }
            else
            {
                MessageBox.Show("Δεν βρέθηκε σύνδεση στο ίντερνετ. Παρακαλώ δοκιμάστε αργότερα");
            }
        }
Exemple #2
0
        public ActionResult RepresentativeQuestions(int repId)
        {
            var service = new QuestionsService();
            var model   = service.GetQuestionMessagesForRepresentative(repId);

            return(PartialView("QuestionMessage/_representativeQuestions", model));
        }
Exemple #3
0
        protected Quiz()
        {
            IQuizRepository   quizRepository   = new QuizRepository();
            IQuestionsService questionsService = new QuestionsService(quizRepository);

            _gameService = new GameService(questionsService);
        }
Exemple #4
0
 public QuestionsFactory()
 {
     this.questionsContainer = new QuestionsContainer();
     this.questionsService   = new QuestionsService();
     this.algorithmService   = new AlgorithmsService();
     this.InitiatePool1();
 }
Exemple #5
0
        public ActionResult LawDetails(int?lawId, string pCode, string scrollPosition, string sp)
        {
            if (lawId == null)
            {
                return(HttpNotFound());
            }

            LawService service = new LawService();
            LawModel   model   = service.GetLawModel(lawId.Value, User.Identity.GetUserId(), Infrastructure.CommentOrder.Chronological);

            if (model == null)
            {
                return(HttpNotFound());
            }

            new ParliamentService().GetTenantData(model.Law.ParliamentID, out string parliamentCode);
            if (pCode == null || pCode != parliamentCode)
            {
                return(RedirectToRoute(JavnaRasprava.Resources.Routes.JavnaRasprava_LawDetails, new { pCode = parliamentCode, lawId }));
            }

            QuestionsService questionsService = new QuestionsService();

            model.RepresentativeAnswers = questionsService.GetLatestAnswersForLaw(lawId.Value, User.Identity.GetUserId());

            ViewBag.scrollPosition = sp ?? scrollPosition;

            model.FbCommentsPath = string.Format(ConfigurationManager.AppSettings["Facebook.LawUrlTemplate"], lawId);

            return(View("Law", model));
        }
Exemple #6
0
        public ActionResult GetLawQuestionModel(int lawId)
        {
            QuestionsService    service = new QuestionsService();
            AskLawQuestionModel model   = service.GetQuestionsModel(lawId, User.Identity.GetUserId());

            return(PartialView("Representatives/_AskRepresentatives", model));
        }
Exemple #7
0
        public async Task GetAllWithObjectsAsyncTest()
        {
            //Arrange

            var mock = new Mock <QuestionsService>();

            mock.Setup(x => x.GetAllWithObjectsAsync().Result).Returns(questions);

            var service = new QuestionsService(db);


            //Act

            // var expected = mock;
            var expected = questions;

            var result = await service.GetAllWithObjectsAsync();


            //Assert
            // Assert.Equal(expected, result);
            result.Should().NotBeEmpty();
            result.Should().BeOfType(typeof(List <Question>));
            result.Should().BeSameAs(expected);
        }
Exemple #8
0
        public void PostQuestion_NoRepresentative_NoQuestions()
        {
            int parliamentID = 1;

            var law1 = Helpers.CreateLaw(parliamentID, new List <string> {
                "AmirFazlic", "AsimSarajlic", "SalkoSokolovic"
            }, new List <string> {
                "First Question", "Second Question"
            });
            var user = Helpers.CreateNewUser();

            try
            {
                var service = new QuestionsService();

                var model = service.GetQuestionsModel(law1.LawID, user.Id);
                model.Text = "Some Text";
                service.PostQuestion(model, user.Id);

                var response = service.GetQuestionsForLaw(law1.LawID, user.Id);

                Assert.AreEqual(2, response.Questions.Count);
            }
            finally
            {
                Helpers.DeleteUser(user);
            }
        }
Exemple #9
0
        public void ShouldReturnFirstQuestion()
        {
            //arrange
            var context   = TestDbContextCreator.CreateInMemory(nameof(ShouldReturnFirstQuestion));
            var questions = TestDataContainer.GetQuestionEntities();

            context.Questions.AddRange(questions);
            context.SaveChanges();

            var sut = new QuestionsService(context);

            var expected = new Question
            {
                Id   = 1,
                Text = "Do I want a doughnut?",
                PositiveAnswerQuestionId = 2,
                NegativeAnswerQuestionId = 3
            };

            //act
            var actual = sut.GetFirstQuestion();

            //assert
            actual.Should().BeEquivalentTo(expected);
        }
Exemple #10
0
        public ActionResult GetLawQuestionsDetails(int lawId)
        {
            QuestionsService  service = new QuestionsService();
            LawQuestionsModel model   = service.GetQuestionsForLaw(lawId, User.Identity.GetUserId());

            return(View("LawQuestionsDetails", model));
        }
Exemple #11
0
        public QuestionsViewModel()
        {
            this.service = new QuestionsService();

            this.UserQuestions = new ObservableCollection <QuestionDTO>(this.service.GetUserQuestions(Authenticator.CurrentUser.Id, Authenticator.CurrentUser.Subject.Id));
            this.Themes        = this.service.LoadThemes(Authenticator.CurrentUser.Subject.Id);
        }
Exemple #12
0
        public ActionResult GetQuestionsModelForRepresentative(int repId)
        {
            QuestionsService service             = new QuestionsService();
            AskRepresentativeQuestionModel model = service.GetQuestionsmodelForRepresentative(repId, User.Identity.GetUserId());

            return(PartialView("_AskRepresentativeQuestion", model));
        }
 public SettingsPage()
 {
     InitializeComponent();
     GetSoundSettings();
     GetUpdateSettings();
     QuestionsCountText.Text = "Σύνολο ερωτήσεων " + QuestionsService.CountQuestions().ToString();
 }
Exemple #14
0
 public TriviaController()
 {
     this.db = new TriviaContext();
     this.questionsService  = new QuestionsService(db);
     this.answersService    = new AnswersService(db);
     this.statisticsService = new StatisticsService(db);
 }
Exemple #15
0
        public void ShouldReturnQuestion()
        {
            //arrange
            var questionEntity = new QuestionEntity
            {
                Id   = 1,
                Text = "Test question"
            };

            var context = TestDbContextCreator.CreateInMemory(nameof(ShouldReturnQuestion));

            context.Questions.Add(questionEntity);
            context.SaveChanges();

            var expected = new Question
            {
                Id   = questionEntity.Id,
                Text = questionEntity.Text
            };

            var sut = new QuestionsService(context);

            //act
            var actual = sut.GetQuestion(questionEntity.Id);

            //assert
            actual.Should().BeEquivalentTo(expected);
        }
Exemple #16
0
        public ActionResult DislikeAnswer(int answerId)
        {
            QuestionsService service = new QuestionsService();

            var model = service.LikeAnswer(answerId, User.Identity.GetUserId(), false);

            return(PartialView("_AnswerLikes", CopyAnswerModelDataToRepresentativeAnswerModel(model)));
        }
Exemple #17
0
        public ActionResult LikeAnswer(int answerId)
        {
            QuestionsService service = new QuestionsService();

            var model = service.LikeAnswer(answerId, User.Identity.GetUserId(), true);

            return(PartialView("_AnswerLikes", model));
        }
Exemple #18
0
        async void Save_Clicked(object sender, EventArgs e)
        {
            var question = await QuestionsService.DoQuestionsAddRequest(Question);

            await Navigation.PopModalAsync();

            viewModel.LoadQuestionsCommand.Execute(null);
        }
        protected async override Task OnInitializedAsync()
        {
            // return base.OnInitializedAsync();

            _questionsService = (QuestionsService)ScopedServices.GetService(typeof(QuestionsService));

            // ModalIsOpen = false;
        }
Exemple #20
0
        public ActionResult LikeQuestion(int questionId)
        {
            QuestionsService service = new QuestionsService();

            var model = service.LikeQuestion(questionId, User.Identity.GetUserId(), true);

            return(PartialView("_QuestionLikes", CopyQuestionModelDataToRepresentativeQuestionModel(model)));
        }
Exemple #21
0
        public ActionResult DislikeQuestion(int questionId)
        {
            QuestionsService service = new QuestionsService();

            var model = service.LikeQuestion(questionId, User.Identity.GetUserId(), false);

            return(PartialView("_QuestionLikes", model));
        }
Exemple #22
0
 public async Task AddAnswer(Guid tenderGuid, QuestionDTO questioDTO)
 {
     using (QuestionsService service = new QuestionsService(tenderGuid))
     {
         var result = await service
                      .AnswerQuestion(questioDTO.StringId, questioDTO.Answer,
                                      "Я хз как что за токен, вставьте кто-то за меня пжалуйста.");
     }
 }
Exemple #23
0
        public ActionResult AskRepresentative(int lawId, AskLawQuestionModel model)
        {
            TryUpdateModel(model);

            QuestionsService service = new QuestionsService();

            service.PostQuestion(model, User.Identity.GetUserId());
            return(PartialView("Representatives/_AskRepresentativesSuccess"));
        }
Exemple #24
0
        public ActionResult SubmitRepresentativeAnswer(RepresentativeAnswerTestModel model)
        {
            QuestionsService service = new QuestionsService();

            TryUpdateModel(model);

            service.PostAnswer(model.QuestionId, model.RepresentativeId, model.Answer);

            return(RedirectToAction("GetLawQuestionsDetails", "JavnaRasprava", new { lawId = model.LawId }));
        }
Exemple #25
0
        public ActionResult AskRepresentative(AskRepresentativeQuestionModel model)
        {
            QuestionsService service = new QuestionsService();

            if (!ModelState.IsValid)
            {
                return(PartialView("_AskRepresentativeQuestion", model));
            }
            service.PostRepresentativeQuestion(model, User.Identity.GetUserId());
            return(PartialView("_AskRepresentativeSuccess", model));
        }
        public async Task CheckCreatingQuestionAsync()
        {
            ApplicationDbContext db = GetDb();

            var repository = new EfDeletableEntityRepository <Question>(db);
            var service    = new QuestionsService(repository);

            await this.PrepareQuestionAsync(service);

            Assert.Equal(1, repository.All().Count());
        }
Exemple #27
0
        public void Setup()
        {
            _fixture = new Fixture().Customize(new AutoMoqCustomization
            {
                ConfigureMembers = true
            });

            _questionsRepositoryMock = _fixture.Freeze <Mock <IQuestionsRepository> >();

            _service = _fixture.Create <QuestionsService>();
        }
Exemple #28
0
        public void Create()
        {
            var repository = new Mock <IDeletableEntityRepository <Question> >();
            var service    = new QuestionsService(repository.Object);

            _ = service.CreateAsync("Title", "Test", "1");

            Assert.Equal(2, repository.Invocations.Count);

            repository.Verify(x => x.All(), Times.Once);
        }
Exemple #29
0
        public void ShouldReturnNullIfFirstQuestionIsMissing()
        {
            //arrange
            var context = TestDbContextCreator.CreateInMemory(nameof(ShouldReturnNullIfFirstQuestionIsMissing));
            var sut     = new QuestionsService(context);

            //act
            var actual = sut.GetFirstQuestion();

            //assert
            actual.Should().BeNull();
        }
Exemple #30
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     try
     {
         Settings.LoadSettings();
         QuestionsList = QuestionsService.GetQuestions();
     }
     catch (Exception exp)
     {
         MessageBox.Show("Κάτι δεν πήγε καλά ... Εργαζόμαστε γι αυτό....." + exp.Message);
     }
 }
        public async void AddVariantQuestion()
        {
            var question = new VariantQuestionModel()
            {
                Content = "Choose an answer!",
                Enabled = true,
                TopicId = 1,
                Type = QuestionType.Radio,
                UserId = 1,
                Variants = new List<VariantModel>()
                {
                    new VariantModel() { Body = "Answer A", Correct = false},
                    new VariantModel() { Body = "Answer B", Correct = false},
                    new VariantModel() { Body = "Answer C", Correct = true},
                }
            };

            IAccountService accountService = new AccountService();
            var resp = await accountService.Authenticate("*****@*****.**", "ion123");
            IQuestionsService service = new QuestionsService(resp.access_token, new JsonSerializer());
            Assert.IsTrue(service.AddQuestion(question.TopicId, question).Result);
        }
        private async void SignInButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (_isAuthenticationBegun)
                return;

            _isAuthenticationBegun = true;

            string email = "ionh";
            string password = "******";

            if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
                return;
            try
            {
                IAccountService accountService = new AccountService();
                var response = await accountService.Authenticate(email, password);

                if (!string.IsNullOrEmpty(response?.access_token))
                {
                    IQuestionsService questionsService = new QuestionsService(response.access_token, new JsonSerializer());
                    var question = new VariantQuestionModel()
                    {
                        Content = "Choose an answer!",
                        Enabled = true,
                        TopicId = 1,
                        Type = QuestionType.Radio,
                        UserId = 1,
                        Variants = new List<VariantModel>
                        {
                            new VariantModel() { Body = "Answer A", Correct = false},
                            new VariantModel() { Body = "Answer B", Correct = false},
                            new VariantModel() { Body = "Answer C", Correct = true},
                         }
                    };
                    var result = await questionsService.AddQuestion(question.TopicId, question);
                    MessageBox.Show(result.ToString());

                    IUsersService usersService = new UsersService(response.access_token,
                        new JsonSerializer());
                    UserModel user = await usersService.GetUser();

                    if (!user.Roles.Any(
                            r => r.Equals(RoleType.Teacher.ToString())
                                || r.Equals(RoleType.Admin.ToString())))
                        return;

                    lock (AuthenticationMonitor)
                    {
                        var mainWindow = new MainWindow(accountService);
                        Close();
                        mainWindow.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                //MessageBox.Show(ex.ToString());
            }

            _isAuthenticationBegun = false;
        }