public async Task <IActionResult> Edit(string id, [Bind("Id,VoteCount,Title,Body,UserId,PostDate")] QuestionsModel questionsModel) { if (id != questionsModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(questionsModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionsModelExists(questionsModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(questionsModel)); }
public async Task <IActionResult> CreateGame(GameModel newGame) { try { //returns IActionResult for pulling questions from external DB var questions = await _questionController.RetrieveQuestions(newGame.TotalQuestions); //creates game in localDB and pulls back GameId var game = await _gameRepo.CreateGame(newGame.OwnerId, newGame.GameName, newGame.TotalQuestions, newGame.IsPublic, newGame.Duration); //adds questions to the question table questions = await _gameRepo.AddQuestions(questions); //creates question list for game, stripping correct and incorrect tags on answers. List <QuestionsModel> appQuestions = QuestionsModel.CreateAndShuffle(questions); //assigns the question to the game. game.Questions = appQuestions; //inserts gameid, playerid, and questionid to answer table. await _gameRepo.LinkGame(game); return(Ok(game)); } catch (Exception) { return(StatusCode(500)); } // return Ok(gamePlayerId); }
//SINAV EKLE public ActionResult AddExam(QuestionsModel qts) { QuestionsDA qda = new QuestionsDA(); qda.AddExam(qts); return(RedirectToAction("Questions")); }
public JsonResult AddQuestions(long GroupTypeVal, string GroupTypeText) { bool isResult = false; int returnResult = 0; try { QuestionsModel question = new QuestionsModel(); question.AssessmentGroupId = GroupTypeVal; question.QuestionText = GroupTypeText.Trim(); question.AgencyId = (Session["AgencyId"] != null) ? new Guid(Session["AgencyId"].ToString()) : (Guid?)null; question.UserId = new Guid(Session["UserID"].ToString()); question.AssessmentGroupId = GroupTypeVal; string command = "CHECKQUESTION"; isResult = new MatrixData().CheckQuestions(question, command); if (isResult) { returnResult = 2; return(Json(returnResult, JsonRequestBehavior.AllowGet)); } isResult = new MatrixData().InsertQuestionType(question); if (isResult) { returnResult = 1; return(Json(returnResult, JsonRequestBehavior.AllowGet)); } } catch (Exception Ex) { clsError.WriteException(Ex); //return Json("Error occured please try again."); } return(Json(isResult, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateQuestions(long GroupType, string Questiontype, long QuestionId) { bool isResult = false; int returnResult = 0; try { QuestionsModel question = new QuestionsModel(); question.AssessmentQuestion = Questiontype; question.AssessmentGroupId = GroupType; question.AssessmentQuestionId = QuestionId; question.UserId = new Guid(Session["UserID"].ToString()); question.AgencyId = (Session["AgencyId"] != null) ? new Guid(Session["AgencyId"].ToString()) : (Guid?)null; const string command = "CHECKQUESTIONUPDATE"; isResult = new MatrixData().CheckQuestions(question, command); if (isResult) { returnResult = 2; return(Json(returnResult, JsonRequestBehavior.AllowGet)); } isResult = new MatrixData().UpdateQuestionType(question); if (isResult) { returnResult = 1; return(Json(returnResult, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { clsError.WriteException(ex); //return Json("Error occured please try again."); } return(Json(returnResult, JsonRequestBehavior.AllowGet)); }
public static QuestionsModel TranslateAsQuestions(this SqlDataReader reader, bool isList = false) { if (!isList) { if (!reader.HasRows) { return(null); } reader.Read(); } var item = new QuestionsModel(); if (reader.IsColumnExists("Id")) { item.Id = SqlHelper.GetNullableInt32(reader, "Id"); } if (reader.IsColumnExists("Question")) { item.Question = SqlHelper.GetNullableString(reader, "Question"); } if (reader.IsColumnExists("TestId")) { item.TestId = SqlHelper.GetNullableInt32(reader, "TestId"); } return(item); }
public ActionResult Question(int IsFiltered) { List <QuestionsModel> objList = new List <QuestionsModel>(); using (var db = new NewRegEntities()) { var query = from question in db.Questions join category in db.Categories on question.CatergoryId equals category.CategoryId select new QuestionsModel() { QuestionId = question.QuestionId, Question = question.Question1, Category = category.CategoryName, CategoryId = category.CategoryId, QuestionDateAndTime = question.QuestionDateAndTime }; foreach (var item in query) { QuestionsModel obj = new QuestionsModel { QuestionId = item.QuestionId, Question = item.Question, CategoryId = item.CategoryId, Category = item.Category, QuestionDateAndTime = item.QuestionDateAndTime }; objList.Add(obj); } } return(View(objList)); }
private static void AddToFeedbackCart(QuestionsModel model, string skipped) { var nvc = FeedbackCart.RatingNVC; switch (model.QType) { case "C": nvc = FeedbackCart.CommentNVC; return; case "O": nvc = FeedbackCart.OtherNVC; skipped = "-1"; break; default: nvc = FeedbackCart.RatingNVC; break; } if (nvc[model.QId] == null) { nvc.Add(model.QId, skipped); } else { nvc.Remove(model.QId); AddToFeedbackCart(model, "0"); } }
public QuestionsViewModel() { questionsModel = new QuestionsModel(); //TODO: Call below function once questios view is laoded. LoadQestions(); }
/// <summary> /// Initializes a new instance of the <see cref="T:CGFSMVVM.ViewModels.EmojiRatingViewModel"/> class. /// </summary> /// <param name="iNavigation">I navigation.</param> /// <param name="currQuestionIndex">Curr question index.</param> public EmojiRatingViewModel(INavigation iNavigation, string currQuestionIndex, StackLayout childLayout, ScrollView scrollView) { this._navigation = iNavigation; this._currQuestionindex = currQuestionIndex; this._childLayout = childLayout; this._scrollView = scrollView; this._Questions = QuestionJsonDeserializer.GetQuestion(currQuestionIndex); this.children = QuestionJsonDeserializer.GetChildQuestionSet(_currQuestionindex); LoadEmojis(); SetChildVisibility("All"); LoadChildGlobalList(); TappedCommand = new Command <EmojiIconModel>(async(emojiIconModel) => await EmojiTapped(emojiIconModel).ConfigureAwait(true)); ChildHeatBarTappedCommand = new Command <Heat_ChildModel>(ChildButtonTapped); LoadQuestionCommand = new Command <Label>(LoadData); LoadMessageTextCommand = new Command <Label>(SetMessageText); LoadChildQuestionCommand = new Command(LoadChildData); BackCommand = new Command(BackButtonTapped); NextCommand = new Command(NextButtonTapped); RestoreFeedbackData(); RestoreChildFeedbackData(); }
public bool InsertResultGreet(QuestionsModel Res, out string Err) { Err = ""; try { if (_VoitingBaseDataContext.QuestGreetings.Any(a => a.EmpId == Res.Empl.Id && a.AnketaId == AnketaId)) { return(true); } QuestGreetings qg = new QuestGreetings() { Greet1 = Res.Greet1.TrimEnd(), Greet2 = Res.Greet2.TrimEnd(), Greet3 = Res.Greet3.TrimEnd(), EmpId = Res.Empl.Id, AnswerDate = DateTime.Now, CompName = Res.CompName, IP = Res.IpAddress, Agent = Res.UserAgent, AnketaId = AnketaId }; _VoitingBaseDataContext.QuestGreetings.InsertOnSubmit(qg); _VoitingBaseDataContext.SubmitChanges(); return(true); } catch (Exception e) { Err = e.Message; return(false); } }
public ActionResult AddSectionTest_Post(QuestionsModel objQuestionData) { if (objQuestionData.Id != 0) { CourseSteps(objQuestionData); } switch (objQuestionData.Text) { case "Add Question": AddNewQuestion(objQuestionData); break; case "Update Question": UpdateQuestion(objQuestionData); break; } TaxCourse objSectionData = new TaxCourse(); objSectionData.Id = objQuestionData.Id; objSectionData.SectionID = objQuestionData.SectionID; return(RedirectToAction("AddSectionTest", objSectionData)); }
public bool InsertResult(QuestionsModel Res) { try { if (_VoitingBaseDataContext.QuestAnswers.Where(a => a.EmpId == Res.Empl.Id && a.AnketaId == AnketaId).Count() > 0) { return(true); } foreach (CQuestion Q in Res.Questions) { QuestAnswers Qa = new QuestAnswers() { //AnketaId = Res.AnketaId, AnketaId = AnketaId, EmpDepNum = Res.Empl.DepId, AnswerDate = DateTime.Now, EmpDepPos = Res.Empl.PosId, EmpId = Res.Empl.Id, QuestionId = Q.QId, Result = Q.Result, Ip = Res.IpAddress, CompName = Res.CompName, Agent = Res.UserAgent }; _VoitingBaseDataContext.QuestAnswers.InsertOnSubmit(Qa); } _VoitingBaseDataContext.SubmitChanges(); return(true); } catch { return(false); } }
public TestQuestionsController() { var mappingConfig = new MapperConfiguration(cfg => { cfg.AddProfile(new JeopardyMappingProfile()); }); model = new QuestionsModel() { Id = 55, QuestionEn = "TestQuestion 1", QuestionFr = "TestQuestion 1 en francais", AnswerEn = "TestAnswer 1", AnswerFr = "TestAnswer 1 en francais", CategoryId = 30, Hint = "Test Hint 1", Points = 100, TimeLimit = 30 }; updateModel = new QuestionsModel() { Id = 32, QuestionEn = "TestQuestion 112434", QuestionFr = "TestQuestion 112434 en francais", AnswerEn = "TestAnswer 1", AnswerFr = "TestAnswer 1 en francais", CategoryId = 30, Hint = "Test Hint 1", Points = 100, TimeLimit = 30 }; var mapper = mappingConfig.CreateMapper(); // Use this mapper to instantiate your class _mapper = mapper; _service = new JeopardyRepositoryFake(testContext); _controller = new QuestionsController(_service, _mapper); }
public ActionResult AskQuestion(QuestionsModel questions) { QuestionsModel objModel = new QuestionsModel(); CategoryDapper objCategoryList = new CategoryDapper(); objModel.CategoryList = new SelectList(objCategoryList.GetList(), "CategoryId", "CategoryName"); ViewBag.CategoryList = objModel.CategoryList; if (ModelState.IsValid) { using (var context = new NewRegEntities()) { var question = new StackOverflow.Models.Question { Question1 = questions.Question, CatergoryId = (int)questions.CategoryId, QuestionDateAndTime = DateTime.Now }; context.Questions.Add(question); context.SaveChanges(); } return(RedirectToAction("Question", new { IsFiltered = 0 })); } return(View("AskQuestion")); }
private async void InitClass() { lstQuestions = await QuestionsModel.ObtenerPreguntas(); CurrentQuestion = lstQuestions.First(); lstAnswers = new ObservableCollection <AnswerOptionModel>(CurrentQuestion.Answers); }
public async Task <IActionResult> Edit(int id, [Bind("QId,Answer,PId,FNId")] QuestionsModel questionsModel) { if (id != questionsModel.QId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(questionsModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionsModelExists(questionsModel.QId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } //ViewData["FNId"] = new SelectList(_context.GetFaultNameModels, "FNId", "Name", questionsModel.FNId); //ViewData["PId"] = new SelectList(_context.GetProfessorModels, "PId", "Name", questionsModel.PId); return(View(questionsModel)); }
public void GetAllInformation(string username) { this.mainM = new MainModel(); this.resumeM = new ResumeModel(); this.miscM = new MiscModel(); this.progM = new ProgramModel(); this.questM = new QuestionsModel();
public void GetClientQuestionSuccess(QuestionsModel model) { question = model; if (question != null) { BindView(); } }
public Task AddAsync(QuestionsModel model) { Question question = mapper.Map <Question>(model); return(Task.Run(() => { UnitOfWork.QuestionRepository.AddAsync(question); UnitOfWork.SaveAsync(); })); }
public ActionResult NewsList() { QuestionsModel model = new QuestionsModel { Questions = _quizService.GetAll().ToList(), }; return(View(model)); }
public ActionResult test(int?id) { QuestionsModel model = new QuestionsModel { Questions = _quizService.GetAll().Where(i => i.Id == id).ToList(), }; return(View(model)); }
public Task UpdateAsync(QuestionsModel model) { var book = mapper.Map <QuestionsModel, Question>(model); return(Task.Run(() => { UnitOfWork.QuestionRepository.Update(book); UnitOfWork.SaveAsync(); })); }
public ActionResult AskQuestion() { QuestionsModel objModel = new QuestionsModel(); CategoryDapper objCategoryList = new CategoryDapper(); objModel.CategoryList = new SelectList(objCategoryList.GetList(), "CategoryId", "CategoryName"); ViewBag.CategoryList = objModel.CategoryList; return(View()); }
public void Instance_Is_PageModel() { var type = typeof(PageModel); var facadeMock = new Mock <IAsk>(); var model = new QuestionsModel(facadeMock.Object); Assert.IsAssignableFrom(type, model); }
public QuestionsModel DetailExam(int ID) { DBUtilities utility = new DBUtilities(); utility.cn.Open(); utility.cmd.CommandText = "Select * From Questions WHERE ID = " + ID; utility.cmd.ExecuteScalar(); SqliteDataReader dr = utility.cmd.ExecuteReader(); QuestionsModel odm = new QuestionsModel(); while (dr.Read()) { odm.ID = Convert.ToInt32(dr["ID"]); odm.Topic = dr["Topic"].ToString().Trim(); odm.Description = dr["Description"].ToString().Trim(); odm.Questions1 = dr["Question1"].ToString().Trim(); odm.Questions2 = dr["Question1"].ToString().Trim(); odm.Questions3 = dr["Question1"].ToString().Trim(); odm.Questions4 = dr["Question1"].ToString().Trim(); odm.ReplyA1 = dr["A1"].ToString().Trim(); odm.ReplyA2 = dr["A2"].ToString().Trim(); odm.ReplyA3 = dr["A3"].ToString().Trim(); odm.ReplyA4 = dr["A4"].ToString().Trim(); odm.ReplyB1 = dr["B1"].ToString().Trim(); odm.ReplyB2 = dr["B2"].ToString().Trim(); odm.ReplyB3 = dr["B3"].ToString().Trim(); odm.ReplyB4 = dr["B4"].ToString().Trim(); odm.ReplyC1 = dr["C1"].ToString().Trim(); odm.ReplyC2 = dr["C2"].ToString().Trim(); odm.ReplyC3 = dr["C3"].ToString().Trim(); odm.ReplyC4 = dr["C4"].ToString().Trim(); odm.ReplyD1 = dr["D1"].ToString().Trim(); odm.ReplyD2 = dr["D2"].ToString().Trim(); odm.ReplyD3 = dr["D3"].ToString().Trim(); odm.ReplyD4 = dr["D4"].ToString().Trim(); odm.TrueReply1 = dr["True1"].ToString().Trim(); odm.TrueReply2 = dr["True2"].ToString().Trim(); odm.TrueReply3 = dr["True3"].ToString().Trim(); odm.TrueReply4 = dr["True4"].ToString().Trim(); } utility.endC(); return(odm); }
public async Task <GameModel> AddPlayerToGame(int gameId, int playerId) { DateTimeOffset _now = DateTimeOffset.Now; var searchGame = await _context.Games.Where(x => x.Id == gameId && DateTimeOffset.Compare(x.EndDate, _now) > 0 && x.IsPublic == true).FirstAsync(); if (searchGame != null) { GameModel appGame = new GameModel { Id = searchGame.Id, GameName = searchGame.GameName, OwnerId = searchGame.OwnerId, StartDate = searchGame.StartDate, EndDate = searchGame.EndDate, GameMode = searchGame.GameMode, IsPublic = searchGame.IsPublic, TotalQuestions = searchGame.TotalQuestions, PlayerId = playerId }; appGame.Questions = new List <QuestionsModel>(); List <int> questionList = await _context.Answers .Where(x => x.GameId == searchGame.Id) .Select(x => x.QuestionId) .Distinct() .ToListAsync(); foreach (var question in questionList) { Question dbQuestion = await _context.Questions .Where(x => x.Id == question).FirstAsync(); var appQuestion = new QuestionsModel(); appQuestion.Answers.Add(dbQuestion.CorrectAnswer); appQuestion.Answers.Add(dbQuestion.IncorrectAnswer1); appQuestion.Answers.Add(dbQuestion.IncorrectAnswer2); appQuestion.Answers.Add(dbQuestion.IncorrectAnswer3); appQuestion.Id = dbQuestion.Id; appQuestion.Question = dbQuestion.Question1; appQuestion.Answers = appQuestion.Answers.Where(x => !string.IsNullOrEmpty(x)).OrderBy(x => Guid.NewGuid()).ToList(); appGame.Questions.Add(appQuestion); } return(appGame); } else { throw new ArgumentException("Game not found"); } }
public async Task <IActionResult> Create([Bind("Id,VoteCount,Title,Body,UserID,PostDate")] QuestionsModel questionsModel) { if (ModelState.IsValid) { _context.Add(questionsModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(questionsModel)); }
public void QuestionId_IsNotWithInBounds_ReturnTrue(int id) { // arrange var question = new QuestionsModel(); int testId = id; // act bool isIdOkay = question.IdIsOkayFromDatabase(testId); // assert Assert.False(isIdOkay); }
public void GetServiceQuestionSuccess(QuestionsModel model) { handler.Post(() => { if (swipeRefreshLayout.Refreshing) { swipeRefreshLayout.Refreshing = false; } question = model; lastDatetime = DateTime.Now; BindView(); }); }