예제 #1
0
        public async Task <IActionResult> SaveAnswers(IFormCollection form)
        {
            var request = new AddAnswers {
                Form = (FormCollection)form
            };
            await _mediator.Send(request);

            return(View("AnswersSubmitted"));
        }
예제 #2
0
        private void AddAnswers_Click(object sender, EventArgs e)
        {
            try
            {
                using (var db = new AcademyEntities())
                {
                    if (db.Questions.Any())
                    {
                        //this.Hide();
                        //var id = Convert.ToInt32(AllQuestionsView.CurrentRow.Cells["Id"].Value);


                        //AddAnswers addAnswers = new AddAnswers(id);
                        //addAnswers.Show();
                        //this.AddOwnedForm(addAnswers);

                        var id = Convert.ToInt32(AllQuestionsView.CurrentRow.Cells["Id"].Value);
                        this.Hide();
                        AddAnswers addAnswers = new AddAnswers(id);
                        addAnswers.Show();
                        this.AddOwnedForm(addAnswers);

                        //if (!(db.Answers.Where(q => q.QuestionId == id).Where(c=>c.Correct==true).Any()))
                        //{
                        //    this.Hide();
                        //    AddAnswers addAnswers = new AddAnswers(id);
                        //    addAnswers.Show();
                        //    this.AddOwnedForm(addAnswers);
                        //}
                        //else
                        //{
                        //    MessageBox.Show("This question already has answers and co!");
                        //}
                    }
                    else
                    {
                        MessageBox.Show("No questions existed!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }