public ActionResult Clone(int fromMatchId, int toMatchId)
        {
            if (db.MatchQuestions.Any(x => x.MatchId == toMatchId))
            {
                ViewBag.ErrorMessage = "Already some questions added";
                ViewBag.fromMatchId  = new SelectList(db.Matches, "MatchId", "Number");
                ViewBag.toMatchId    = new SelectList(db.Matches, "MatchId", "Number");
                return(View());
            }
            var questions = db.MatchQuestions.Where(x => x.MatchId == fromMatchId).ToList();

            foreach (var fromQuestion in questions)
            {
                var toQuestion = new MatchQuestion()
                {
                    MatchId = toMatchId,
                    PredictionCategoryId = fromQuestion.PredictionCategoryId,
                    QuestionId           = fromQuestion.QuestionId
                };
                db.MatchQuestions.Add(toQuestion);
            }

            db.SaveChanges();

            return(RedirectToAction("Index", new { matchId = toMatchId }));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            MatchQuestion matchQuestion = db.MatchQuestions.Find(id);

            db.MatchQuestions.Remove(matchQuestion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(MatchQuestion matchQuestion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(matchQuestion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { matchId = matchQuestion.MatchId }));
     }
     ViewBag.MatchId = new SelectList(db.Matches, "MatchId", "Number", matchQuestion.MatchId);
     ViewBag.PredictionCategoryId = new SelectList(db.PredictionCategories, "PredictionCategoryId", "Name", matchQuestion.PredictionCategoryId);
     ViewBag.QuestionId           = new SelectList(db.Questions.Where(x => x.IsForMatch == true), "QuestionId", "Text", matchQuestion.QuestionId);
     return(View(matchQuestion));
 }
        // GET: MatchQuestion/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MatchQuestion matchQuestion = db.MatchQuestions.Find(id);

            if (matchQuestion == null)
            {
                return(HttpNotFound());
            }
            return(View(matchQuestion));
        }
        // GET: MatchQuestion/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MatchQuestion matchQuestion = db.MatchQuestions.Find(id);

            if (matchQuestion == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MatchId = new SelectList(db.Matches, "MatchId", "Number", matchQuestion.MatchId);
            ViewBag.PredictionCategoryId = new SelectList(db.PredictionCategories, "PredictionCategoryId", "Name", matchQuestion.PredictionCategoryId);
            ViewBag.QuestionId           = new SelectList(db.Questions.Where(x => x.IsForMatch == true), "QuestionId", "Text", matchQuestion.QuestionId);
            return(View(matchQuestion));
        }
Пример #6
0
        public bool SaveList(IList list)
        {
            ISession     session     = this.sessionFactory.OpenSession();
            ITransaction transaction = session.BeginTransaction();
            bool         result;

            try
            {
                foreach (object obj in list)
                {
                    MatchQuestion matchQuestion = (MatchQuestion)obj;
                    session.Save(matchQuestion);
                }
                transaction.Commit();
                result = true;
            }
            catch
            {
                transaction.Rollback();
                result = false;
            }
            return(result);
        }
Пример #7
0
        public ActionResult BeforeMatchQuestion(StartedFirstQuestion question)
        {
            GolGuru.Instance.SetMatchEquipo1(question.equipo1);

            GolGuru.Instance.SetMatchEquipo2(question.equipo2);

            GolGuru.Instance.SetMatchHour(question.horario);


            var match = db.MatchQuestions.Where(r => r.Datetime.Value.Date == DateTime.Now.Date);

            if (!db.MatchQuestions.Any(r => r.Datetime.Value.Date == DateTime.Now.Date))
            {
                var question1 = new MatchQuestion()
                {
                    Datetime   = DateTime.Now,
                    IsActive   = true,
                    Question   = "Quien va a ganar el partido?",
                    QuestionId = Convert.ToInt16(GolGuru.Instance.GetMatchLiveQuestionId())
                };


                db.MatchQuestions.InsertOnSubmit(question1);

                var question2 = new MatchQuestion()
                {
                    Datetime   = DateTime.Now,
                    IsActive   = true,
                    Question   = "Quien va a tener más la pelota?",
                    QuestionId = Convert.ToInt16(GolGuru.Instance.GetMatchLiveQuestionId())
                };
                db.MatchQuestions.InsertOnSubmit(question2);

                var question3 = new MatchQuestion()
                {
                    Datetime   = DateTime.Now,
                    IsActive   = true,
                    Question   = "Quien va a rematar más al arco?",
                    QuestionId = Convert.ToInt16(GolGuru.Instance.GetMatchLiveQuestionId())
                };
                db.MatchQuestions.InsertOnSubmit(question3);
                var question4 = new MatchQuestion()
                {
                    Datetime   = DateTime.Now,
                    IsActive   = true,
                    Question   = "Quien va a cometer más faltas?",
                    QuestionId = Convert.ToInt16(GolGuru.Instance.GetMatchLiveQuestionId())
                };
                db.MatchQuestions.InsertOnSubmit(question4);

                var question5 = new MatchQuestion()
                {
                    Datetime   = DateTime.Now,
                    IsActive   = true,
                    Question   = "Quien va a tener más corners a favor?",
                    QuestionId = Convert.ToInt16(GolGuru.Instance.GetMatchLiveQuestionId())
                };
                db.MatchQuestions.InsertOnSubmit(question5);

                var question6 = new MatchQuestion()
                {
                    Datetime   = DateTime.Now,
                    IsActive   = true,
                    Question   = "Quien va a recibir más amarillas?",
                    QuestionId = Convert.ToInt16(GolGuru.Instance.GetMatchLiveQuestionId())
                };
                db.MatchQuestions.InsertOnSubmit(question6);
                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            GolGuru.Instance.SetMatchStatus(Helpers.Helpers.MatchStatusEnum.NotStarted);
            return(RedirectToAction("MainMenu", "Home"));
        }
 public void Answer([FromBody] MatchQuestion matchQuestion)
 {
     MatchQuestions.Answer(matchQuestion, Request.Headers["Authorization"].ToString().Remove(0, 7));
 }
 public JsonResult Remove([FromBody] MatchQuestion matchQuestion)
 {
     return(new JsonResult(MatchQuestions.Remove(matchQuestion)));
 }
 public JsonResult Update([FromBody] MatchQuestion matchQuestion)
 {
     return(new JsonResult(MatchQuestions.Update(matchQuestion)));
 }
        public JsonResult AddOverriden([FromBody] MatchQuestion matchQuestion)
        {
            MatchQuestions.AddOverriden(matchQuestion, Request.Headers["Authorization"].ToString().Remove(0, 7));

            return(new JsonResult(MatchQuestions.IncreaseProgress(Request.Headers["Authorization"].ToString().Remove(0, 7), "matchquestion")));
        }
 public JsonResult Add([FromBody] MatchQuestion matchQuestion)
 {
     return(new JsonResult(MatchQuestions.Add(matchQuestion)));
 }
Пример #13
0
        public static Paper Re_ConstructPaper(Paper oPaper, SubmitPaper submitPaper)
        {
            Paper spaper = submitPaper.SPaper;

            foreach (object obj in spaper.ReadingQuestions)
            {
                Passage passage  = (Passage)obj;
                Passage passage2 = QuestionHelper.GetPassage(oPaper, passage.PID);
                passage.Text     = passage2.Text;
                passage.CourseId = passage2.CourseId;
                foreach (object obj2 in passage.PassageQuestions)
                {
                    Question sq = (Question)obj2;
                    foreach (object obj3 in passage2.PassageQuestions)
                    {
                        Question oq = (Question)obj3;
                        if (QuestionHelper.ReConstructQuestion(sq, oq))
                        {
                            break;
                        }
                    }
                }
            }
            foreach (object obj4 in spaper.MatchQuestions)
            {
                MatchQuestion matchQuestion = (MatchQuestion)obj4;
                foreach (object obj5 in oPaper.MatchQuestions)
                {
                    MatchQuestion matchQuestion2 = (MatchQuestion)obj5;
                    if (matchQuestion.MID == matchQuestion2.MID)
                    {
                        matchQuestion.CourseId = matchQuestion2.CourseId;
                        matchQuestion.ColumnA  = matchQuestion2.ColumnA;
                        matchQuestion.ColumnB  = matchQuestion2.ColumnB;
                        matchQuestion.Solution = matchQuestion2.Solution;
                        break;
                    }
                }
            }
            foreach (object obj6 in spaper.GrammarQuestions)
            {
                Question sq = (Question)obj6;
                foreach (object obj7 in oPaper.GrammarQuestions)
                {
                    Question oq = (Question)obj7;
                    if (QuestionHelper.ReConstructQuestion(sq, oq))
                    {
                        break;
                    }
                }
            }
            foreach (object obj8 in spaper.IndicateMQuestions)
            {
                Question sq = (Question)obj8;
                foreach (object obj9 in oPaper.IndicateMQuestions)
                {
                    Question oq = (Question)obj9;
                    if (QuestionHelper.ReConstructQuestion(sq, oq))
                    {
                        break;
                    }
                }
            }
            foreach (object obj10 in spaper.FillBlankQuestions)
            {
                Question sq = (Question)obj10;
                foreach (object obj11 in oPaper.FillBlankQuestions)
                {
                    Question oq = (Question)obj11;
                    if (QuestionHelper.ReConstructQuestion(sq, oq))
                    {
                        break;
                    }
                }
            }
            if (oPaper.EssayQuestion != null)
            {
                QuestionHelper.ReConstructEssay(spaper.EssayQuestion, oPaper.EssayQuestion);
            }
            spaper.AudioData = oPaper.AudioData;
            return(spaper);
        }