private void Add_Click(object sender, RoutedEventArgs e)
 {
     if (Reply != null && MoveToFAQ != null)
     {
         if ((bool)MoveToFAQ.IsChecked)
         {
             Questions.selectedQuestion.question.FrequentlyAsked = true;
             QuestionReply questionReply = new QuestionReply();
             questionReply.Author  = MainWindow.doctor;
             questionReply.Content = Reply.Text;
             questionReply.Date    = DateTime.Today;
             questionController.AnswerQuestion(Questions.selectedQuestion.question, questionReply);
         }
         else
         {
             Questions.selectedQuestion.question.FrequentlyAsked = false;
             QuestionReply questionReply = new QuestionReply();
             questionReply.Author  = MainWindow.doctor;
             questionReply.Content = Reply.Text;
             questionReply.Date    = DateTime.Today;
             questionController.AnswerQuestion(Questions.selectedQuestion.question, questionReply);
         }
         Replies.Navigate(new Uri("/Pages/BlogPages/Questions.xaml", UriKind.Relative));
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> PutQuestionReply([FromRoute] int id, [FromBody] QuestionReply questionReply)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != questionReply.QuestionReplyId)
            {
                return(BadRequest());
            }

            _context.Entry(questionReply).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuestionReplyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> PostQuestionReply(QuestionReply question)
        {
            if (User.Identity.IsAuthenticated)
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid model state"));
                }
                question.time     = DateTime.UtcNow;
                question.postedBy = User.Identity.GetUserId();
                db.QuestionReplies.Add(question);
                await db.SaveChangesAsync();

                var ret = db.QuestionReplies.Where(x => x.Id == question.Id).Select(x => new
                {
                    id           = x.Id,
                    description  = x.description,
                    postedById   = x.AspNetUser.Id,
                    postedByName = x.AspNetUser.Email,
                    time         = x.time
                }).FirstOrDefault();
                return(Ok(ret));
            }
            return(BadRequest("Not login"));
        }
Esempio n. 4
0
        public Question AnswerQuestion(Question question, QuestionReply questionReply)
        {
            Question questionToUpdate = questionRepository.GetObject(question.Id);

            questionToUpdate.QuestionReply = questionReply;
            notificationService.QuestionReplyNotification(questionToUpdate);
            return(questionRepository.Update(questionToUpdate));
        }
Esempio n. 5
0
        public async Task <IHttpActionResult> VoteQuestionReply(int id, bool isup)
        {
            var userId = User.Identity.GetUserId();

            if (userId != null)
            {
                QuestionReply comment = await db.QuestionReplies.FindAsync(id);

                var commentVoteByUser = await db.QuestionReplyVotes.FirstOrDefaultAsync(x => x.questionReplyId == id && x.votedBy == userId);

                if (comment == null)
                {
                    return(NotFound());
                }
                var vote = commentVoteByUser;
                if (vote != null)
                {
                    if (vote.isUp && isup)
                    {
                        return(BadRequest("You have already voteup"));
                    }
                    else if (vote.isUp && !isup)
                    {
                        vote.isUp = false;
                    }
                    else if (!vote.isUp && !isup)
                    {
                        return(BadRequest("You have already votedown"));
                    }
                    else if (!vote.isUp && isup)
                    {
                        vote.isUp = true;
                    }
                }
                else
                {
                    QuestionReplyVote repvote = new  QuestionReplyVote();
                    repvote.isUp            = isup;
                    repvote.votedBy         = userId;
                    repvote.questionReplyId = id;
                    db.QuestionReplyVotes.Add(repvote);
                }
                await db.SaveChangesAsync();

                var q = (from x in comment.QuestionReplyVotes.Where(x => x.questionReplyId == comment.Id)
                         let voteUp = comment.QuestionReplyVotes.Count(m => m.isUp)
                                      let voteDown = comment.QuestionReplyVotes.Count(m => m.isUp == false)
                                                     select new { voteUpCount = voteUp, voteDownCount = voteDown }).FirstOrDefault();

                return(Ok(q));
            }
            else
            {
                return(BadRequest("You are not login"));
            }
        }
Esempio n. 6
0
        public async Task <IActionResult> PostQuestionReply([FromBody] QuestionReply questionReply)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.QuestionReplies.Add(questionReply);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetQuestionReply", new { id = questionReply.QuestionReplyId }, questionReply));
        }
Esempio n. 7
0
 void OnApplicationFocus(bool pauseStatus)
 {
     if (isPaused)
     {
         catReply        = null;
         questionCounter = 0;
         totalQuestion   = 0;
         SceneManager.LoadScene("TriviaResult");
     }
     else
     {
         catReply        = null;
         questionCounter = 0;
         totalQuestion   = 0;
         SceneManager.LoadScene("TriviaResult");
     }
 }
Esempio n. 8
0
    public void Start()
    {
        if (CategoryConstant.GameType.Equals("fun"))
        {
            if (GameConstant.CurrentScore > GameConstant.FunHighScore)
            {
                //highScoreLable.Text = gameConsatant.currentScore.ToString();
                highScoreLable.Text = CategoryConstant.PrizeTopScore.ToString();
            }
            else
            {
                //highScoreLable.Text = gameConsatant.FunHighScore.ToString();
                highScoreLable.Text = CategoryConstant.PrizeTopScore.ToString();
            }
        }
        //Debug.Log("Score = "+gameConsatant.currentScore.ToString());

        //countObj.start ();
        if (catReply == null)
        {
            HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

            new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_questions.php?category_id=" + CategoryConstant.MainCategoryId + "&parent_id=" + CategoryConstant.SubCategoryId + "&grand_parant_id=" + CategoryConstant.GrandCategoryId)
            .OnReply(reply =>
            {
                catReply = JsonConvert.DeserializeObject <QuestionReply>(reply.DataAsString);

                if (catReply.success == 1)
                {
                    totalQuestion = catReply.data.Count;
                    StartRound();
                }
            })
            .Send();
        }
        else
        {
            StartRound();
        }


        //mainPanel.IsVisible = false;
        //StartCoroutine(Wait(2.0f));
        //Invoke( "LoadNewLevel", 5 );
    }
Esempio n. 9
0
        public async Task <IHttpActionResult> updateQuestionReply(QuestionReply comment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            db.Entry(comment).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 10
0
        public async Task <IHttpActionResult> DeleteQuestionReply(int id)
        {
            QuestionReply comment = await db.QuestionReplies.FindAsync(id);

            if (comment == null)
            {
                return(NotFound());
            }

            db.QuestionReplies.Remove(comment);
            try {
                await db.SaveChangesAsync();
            }
            catch (Exception e)
            {
                string s = e.ToString();
            }
            return(Ok(comment));
        }
Esempio n. 11
0
 public ReplyVM(Question q, QuestionReply qr, Report r)
 {
     Question = q; Reply = qr ?? new QuestionReply {
         Question = q, QuestionId = q.QuestionId, ReportId = r.ReportId
     };
 }
Esempio n. 12
0
 public ReplyVM()
 {
     Reply = new QuestionReply();
 }
Esempio n. 13
0
 public Question AnswerQuestion(Question question, QuestionReply questionReply) => questionService.AnswerQuestion(question, questionReply);
Esempio n. 14
0
    public void StartRound()
    {
        Color32 myNewColor = new Color32(196, 115, 7, 255);      //RBGA in bytes

        //answer1.BackgroundColor = myNewColor;
        //answer2.BackgroundColor = myNewColor;
        //answer3.BackgroundColor = myNewColor;
        //answer4.BackgroundColor = myNewColor;

        if (questionCounter < totalQuestion)
        {
            int showNumber = questionCounter + 1;
            question_no.Text = "Question " + showNumber + " of 10";

            answer1.IsEnabled = true;
            answer2.IsEnabled = true;
            answer3.IsEnabled = true;
            answer4.IsEnabled = true;

            answer1.Texture = Resources.Load("checked_field_bg") as Texture2D;
            answer2.Texture = Resources.Load("checked_field_bg") as Texture2D;
            answer3.Texture = Resources.Load("checked_field_bg") as Texture2D;
            answer4.Texture = Resources.Load("checked_field_bg") as Texture2D;


            //string aaa = catReply.data[questionCounter].qu_text;//text to decode.
            //string b = aaa.Replace("&#039;", "'");
            //questionLable.Text = b.Replace("&quot;", "\"");

            questionLable.Text = DecodeString(catReply.data[questionCounter].qu_text);

            countTexture1.Texture = Resources.Load("yellow_num_bg") as Texture2D;
            countTexture2.Texture = Resources.Load("yellow_num_bg") as Texture2D;
            countTexture3.Texture = Resources.Load("yellow_num_bg") as Texture2D;
            countTexture4.Texture = Resources.Load("yellow_num_bg") as Texture2D;

            countTexture1.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor;
            countTexture2.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor;
            countTexture3.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor;
            countTexture4.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor;

            countTexture1.GetComponentInChildren <dfLabel>().IsVisible = true;
            countTexture2.GetComponentInChildren <dfLabel>().IsVisible = true;
            countTexture3.GetComponentInChildren <dfLabel>().IsVisible = true;
            countTexture4.GetComponentInChildren <dfLabel>().IsVisible = true;

            answer_text1.Text = DecodeString(catReply.data[questionCounter].qu_option1);
            answer_text2.Text = DecodeString(catReply.data[questionCounter].qu_option2);
            answer_text3.Text = DecodeString(catReply.data[questionCounter].qu_option3);
            answer_text4.Text = DecodeString(catReply.data[questionCounter].qu_option4);

            //  check if answer 1
            if (catReply.data[questionCounter].qu_answer == 1)
            {
                answer1.GetComponent <answerQuestion>().isCorrect = true;
            }
            else
            {
                answer1.GetComponent <answerQuestion>().isCorrect = false;
            }
            //  check if answer 2
            if (catReply.data[questionCounter].qu_answer == 2)
            {
                answer2.GetComponent <answerQuestion>().isCorrect = true;
            }
            else
            {
                answer2.GetComponent <answerQuestion>().isCorrect = false;
            }
            //  check if answer 3
            if (catReply.data[questionCounter].qu_answer == 3)
            {
                answer3.GetComponent <answerQuestion>().isCorrect = true;
            }
            else
            {
                answer3.GetComponent <answerQuestion>().isCorrect = false;
            }
            //  check if answer 4
            if (catReply.data[questionCounter].qu_answer == 4)
            {
                answer4.GetComponent <answerQuestion>().isCorrect = true;
            }
            else
            {
                answer4.GetComponent <answerQuestion>().isCorrect = false;
            }
            //  end

            answer1.GetComponent <answerQuestion>().questionDifficulty = catReply.data[questionCounter].qu_difficulty;
            answer2.GetComponent <answerQuestion>().questionDifficulty = catReply.data[questionCounter].qu_difficulty;
            answer3.GetComponent <answerQuestion>().questionDifficulty = catReply.data[questionCounter].qu_difficulty;
            answer4.GetComponent <answerQuestion>().questionDifficulty = catReply.data[questionCounter].qu_difficulty;

            //Debug.Log(catReply.data[questionCounter].qu_text);
            //Debug.Log(catReply.data[questionCounter].qu_answer);

            countObj.start();
        }
        else
        {
            Debug.Log("Game Over");
            catReply        = null;
            questionCounter = 0;
            totalQuestion   = 0;
            SceneManager.LoadScene("TriviaResult");
        }
    }