public void GetQuestionsFromDatabase(int questionsEachCategory) { DatabaseConnection.ReadQuestionOptions options = new DatabaseConnection.ReadQuestionOptions { Number = questionsEachCategory }; List <Question> questions = DatabaseConnection.ReadQuestionsFromDatabase(options); foreach (Question question in questions) { CategoryQuestions catQuest = CategoryQuestionList.FirstOrDefault(q => q.Category == question.CategoryList[0]); if (catQuest == null) { CategoryQuestions catQ = new CategoryQuestions { Category = question.CategoryList[0], //TODO: Needs to be fixed for multi category systems Questions = new List <Question>() }; catQ.Questions.Add(question); CategoryQuestionList.Add(catQ); } else { catQuest.Questions.Add(question); } } CategoryQuestionList = CategoryQuestionList.OrderBy(x => Random.value).ToList(); }
public bool Edit(int id, CategoryQuestions par) { bool res = false; try { SBH_TM_CATEGORY_QUESTIONS a = _ctx.SBH_TM_CATEGORY_QUESTIONS.Find(id); if (a != null) { a.CATEGORY_DESC = par.CATEGORY_DESC; a.LAST_MODIFIED_TIME = DateTime.Now; a.LAST_MODIFIED_BY = par.LAST_MODIFIED_BY; _ctx.Entry(a).State = System.Data.Entity.EntityState.Modified; _ctx.SaveChanges(); res = true; } } catch (Exception ex) { throw new Exception(ex.Message); } return(res); }
public List <CategoryQuestions> GridBind() { try { List <CategoryQuestions> lA = new List <CategoryQuestions>(); foreach (var item in _ctx.SBH_TM_CATEGORY_QUESTIONS .Where(x => x.ROW_STATUS == fn.fg.IsActive)) { CategoryQuestions oA = new CategoryQuestions(); oA.ID = item.ID; oA.CATEGORY_DESC = item.CATEGORY_DESC; oA.CREATED_TIME = item.CREATED_TIME; oA.CREATED_BY = item.CREATED_BY; oA.LAST_MODIFIED_TIME = item.LAST_MODIFIED_TIME; oA.LAST_MODIFIED_BY = item.LAST_MODIFIED_BY; oA.ROW_STATUS = item.ROW_STATUS; lA.Add(oA); } return(lA); } catch (Exception ex) { throw new Exception(ex.Message); } }
public CategoryQuestions Retrived(int id) { try { CategoryQuestions oA = new CategoryQuestions(); SBH_TM_CATEGORY_QUESTIONS oB = _ctx.SBH_TM_CATEGORY_QUESTIONS .Where(x => x.ROW_STATUS == fn.fg.IsActive && x.ID == id).FirstOrDefault(); if (oB != null) { oA.ID = oB.ID; oA.CATEGORY_DESC = oB.CATEGORY_DESC; oA.CREATED_TIME = oB.CREATED_TIME; oA.CREATED_BY = oB.CREATED_BY; oA.LAST_MODIFIED_TIME = oB.LAST_MODIFIED_TIME; oA.LAST_MODIFIED_BY = oB.LAST_MODIFIED_BY; oA.ROW_STATUS = oB.ROW_STATUS; return(oA); } else { return(null); } } catch (Exception ex) { return(null); throw new Exception(ex.Message); } }
public void LoadCultivosSurvey(string Category) { currentQuestion = 0; playerAttempts = 1; var cultivosSurvey = Cuestionarios.FirstOrDefault(s => s.SurveyName == "Cultivos"); CurrentSurvey = cultivosSurvey.Categories.FirstOrDefault(c => c.Category == Category); txtCorrectFeedback.text = cultivosSurvey.CorrectFeedBack; txtIncorrectFeedback.text = cultivosSurvey.wrongFeedback; Randomizer.Randomize(CurrentSurvey.questions); UpdateQuestionUI(); UIManager.Instance.ShowSurveyScreen(); }
public void LoadAnimalSurvey(string Category) { UIManager.Instance.EnableBlockPanel(); currentQuestion = 0; playerAttempts = 1; var AnimalsSurvey = Cuestionarios.FirstOrDefault(s => s.SurveyName == "Animales"); CurrentSurvey = AnimalsSurvey.Categories.FirstOrDefault(c => c.Category == Category); txtCorrectFeedback.text = AnimalsSurvey.CorrectFeedBack; txtIncorrectFeedback.text = AnimalsSurvey.wrongFeedback; Randomizer.Randomize(CurrentSurvey.questions); UpdateQuestionUI(); UIManager.Instance.ShowSurveyScreen(); }
public TransactionResult AddCategoryQuestion(CategoryQuestions categoryQuestions) { try { _dbContext.CategoryQuestions.Add(categoryQuestions); _dbContext.SaveChanges(); return(new TransactionResult() { Type = TransactionType.Success }); } catch (Exception ex) { return(new TransactionResult(message: ex.Message, type: TransactionType.Error)); } }
public ActionResult AddData(CategoryQuestions par) { par.CREATED_BY = Session["UserName"].ToString(); par.CREATED_TIME = DateTime.Now; var isSave = repo.Add(par); if (isSave) { TempData["msgSuccess"] = fn.fg.Save; } else { TempData["msgError"] = fn.fg.SFailed; } return(RedirectToAction("ListCategory", "CategoryQuestions")); }
public ActionResult Detail(CategoryQuestions par) { if (!ModelState.IsValid) { TempData["msgError"] = fn.fg.DataIsntValid; } else { par.LAST_MODIFIED_BY = Session["UserName"].ToString(); var isEdit = repo.Edit(par.ID, par); if (isEdit) { TempData["msgSuccess"] = fn.fg.Edit; } else { TempData["msgError"] = fn.fg.EFailed; } } return(RedirectToAction("ListCategory", "CategoryQuestions")); }
public bool Add(CategoryQuestions par) { bool res = false; try { SBH_TM_CATEGORY_QUESTIONS a = new SBH_TM_CATEGORY_QUESTIONS() { CATEGORY_DESC = par.CATEGORY_DESC, CREATED_TIME = par.CREATED_TIME, CREATED_BY = par.CREATED_BY, ROW_STATUS = fn.fg.IsActive }; _ctx.SBH_TM_CATEGORY_QUESTIONS.Add(a); _ctx.SaveChanges(); res = true; } catch (Exception ex) { throw new Exception(ex.Message); } return(res); }