public async Task <IActionResult> CreateQuestion([FromBody] CreateQuestionCmd cmd) { QuestionWriteContext ctx = new QuestionWriteContext(new EFList <Post>(_dbContext.Post)); var dependencies = new QuestionDependencies(); dependencies.QuestionEmail = SendEmail; var exp = from CreateQuestionResult in QuestionContext.CreateQuestion(cmd) select CreateQuestionResult; var r = await _interpreter.Interpret(exp, ctx, dependencies); _dbContext.SaveChanges(); return(r.Match( created => (IActionResult)Ok("Question posted"), notCreated => StatusCode(StatusCodes.Status500InternalServerError, "Question could not be posted.") )); }
private LoadOperation <ProductManager.Web.Model.questiontrace> LoadQuestionTraceEntities() { this.IsBusy = true; EntityQuery <ProductManager.Web.Model.questiontrace> lQuery = this.ProductDomainContext.GetQuestiontraceQuery(); if (!String.IsNullOrEmpty(QuestionContext)) { lQuery = lQuery.Where(c => c.question_descript.ToLower().Contains(QuestionContext.ToLower())); } if (QuestionRspDepartmentID.HasValue && QuestionRspDepartmentID.Value != 0) { lQuery = lQuery.Where(c => c.question_res_departmentid == QuestionRspDepartmentID.Value); } if (QuestionTraceDepartmentID.HasValue && QuestionTraceDepartmentID.Value != 0) { lQuery = lQuery.Where(c => c.question_trace_departmendid == QuestionTraceDepartmentID.Value); } if (QuestionStartTime.HasValue) { lQuery = lQuery.Where(c => c.question_starttime >= QuestionStartTime.Value); } if (QuestionEndTime.HasValue) { lQuery = lQuery.Where(c => c.question_starttime <= QuestionEndTime.Value); } if (AnswerStartTime.HasValue) { lQuery = lQuery.Where(c => c.question_lastanswertime >= AnswerStartTime.Value); } if (AnswerEndTime.HasValue) { lQuery = lQuery.Where(c => c.question_lastanswertime <= AnswerEndTime.Value); } return(this.ProductDomainContext.Load(lQuery.SortAndPageBy(this.questionTraceView))); }
// GET: AnswerQuestion public ViewResult AnswerQuestion() { QuestionContext qt = new QuestionContext(); ParentModel question = new ParentModel(false); try { question = qt.GetQuestionOfTheDay(); } catch (MissingMemberException) { question.Question.Question = "There isn't question of the day ;("; } catch (Exception) { throw new Exception(); } return(View(question)); }
public async Task <IActionResult> CreateQuestion([FromBody] QuestionCmd cmd) { var dep = new QuestionDependencies(); //var question = await _dbContext.QuestionDB.ToListAsync(); var ctx = new WriteContext(); var expr = from CreateTenantResult in QuestionContext.CreateQuestion(cmd) select CreateTenantResult; var r = await _interpreter.Interpret(expr, ctx, dep); await _dbContext.SaveChangesAsync(); return(r.Match( succ => (IActionResult)Ok(succ), fail => BadRequest("Error") )); }
public async Task <IActionResult> CreateQuestion([FromBody] CreateQuestionCmd cmd) { var dep = new QuestionDependencies(); var questions = await _dbContext.Questions.ToListAsync(); var ctx = new QuestionWriteContext(new EFList <Questions>(_dbContext.Questions)); var expr = from createQuestionResult in QuestionContext.CreateQuestion(cmd) select createQuestionResult; var r = await _interpreter.Interpret(expr, ctx, dep); _dbContext.Questions.Add(new DatabaseModel.Models.Questions { QuestionId = Guid.NewGuid(), Title = cmd.Title, Body = cmd.Body, Tags = cmd.Tags }); await _dbContext.SaveChangesAsync(); return(r.Match( created => (IActionResult)Ok(created.Body), notcreated => BadRequest("NotPosted"), invalidRequest => ValidationProblem() )); }
public void Exec(SubCommandRunningContext context) { string name = null; string path = null; try { var config = new DefaultConfigModel(); var questionContext = new QuestionContext { Quite = _options.Quiet }; foreach (var question in _selectorQuestions) { question.Process(config, questionContext); } if (questionContext.ContainsMetadata) { foreach (var question in _metadataQuestions) { question.Process(config, questionContext); } } foreach (var question in _buildQuestions) { question.Process(config, questionContext); } name = string.IsNullOrEmpty(_options.Name) ? ConfigName : _options.Name; path = string.IsNullOrEmpty(_options.OutputFolder) ? name : Path.Combine(_options.OutputFolder, name); JsonUtility.Serialize(path, config, Formatting.Indented); Logger.LogInfo($"Generated {name} to {path}"); } catch (Exception e) { throw new DocfxInitException($"Error init { name ?? ConfigName}: {e.Message}", e); } }
public async Task <IActionResult> CreateQuestion([FromBody] CreateQuestionCmd cmd) { var dep = new QuestionsDependencies(); var replies = await _dbContext.Questions.ToListAsync(); _dbContext.Questions.AttachRange(replies); var ctx = new QuestionsWriteContextC(new EFList <Question>(_dbContext.Questions)); var expr = from createTenantResult in QuestionContext.CreateQuestion(cmd) from checkLanguageResult in QuestionContext.CheckLanguage(new CheckLanguageCmd(cmd.Text)) select createTenantResult; var r = await _interpreter.Interpret(expr, ctx, dep); return(r.Match( created => Ok(created), notCreated => BadRequest(notCreated), invalidRequest => ValidationProblem() )); }
public ActionResult Move(int id, bool isMoveUp) { try { using (var dataContext = new HuntingEntities()) { var user = AclUserContext.GetDetail(dataContext, User.Identity.Name); if (user == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Home")); } var question = QuestionContext.GetDetail(dataContext, id); if (question == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_FOUND); return(RedirectToAction("Index", "Home")); } if (user.CanUpdateTerritory(question.Questionnaire.MapItemType.Territory) == false) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Territory", new { id = question.Questionnaire.MapItemType.TerritoryId })); } var isSuccess = QuestionContext.Move(dataContext, question.Questionnaire, question.Id, isMoveUp, user); if (isSuccess == false) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, QuestionRes.ERROR_MOVE); } return(RedirectToAction("Index", "Question", new { id = question.QuestionnaireId })); } } catch (Exception exception) { logger.Error(exception, "QuestionController"); ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Danger, GlobalRes.ERROR_EXCEPTION); return(RedirectToAction("Index", "Home")); } }
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); FixSnakeCaseNames(builder); UserContext.Build(builder); UserMetadataContext.Build(builder); MetadataTypeReferenceContext.Build(builder); UserAnswerContext.Build(builder); UserQuestionContext.Build(builder); QuestionReportContext.Build(builder); QuestionContext.Build(builder); QuestionLocalizationContext.Build(builder); QuestionTypeReferenceContext.Build(builder); AnswerContext.Build(builder); AnswerLocalizationContext.Build(builder); LocalizationContext.Build(builder); LocaleReferenceContext.Build(builder); }
public ActionResult CreateChart(int id) { //arr should be answers of question -- DB var arr = new string[] { "answ1", "answ2", "answ3", "answ4" }; Chart myChart = new Chart(width: 600, height: 400) //Q name - DB .AddTitle("Do you like the coffee?"); List <AnswerModel> a = new QuestionContext().SelectAnswers(id); foreach (var item in a) { myChart.AddSeries( name: item.Text, //xValue - static xValue: new[] { "<1", "1 - 3", "3 - 5", ">5", ">10" }, //yValue - from the DB Coun (*) yValues: new[] { "2", "6", "4", "5", "3" }) .AddLegend(); } myChart.Write("png"); return(null); }
public async Task <ActionResult <QuestionItemDTO> > PostQuestionItem( [FromServices] QuestionContext context, [FromBody] QuestionItemDTO questionItemDTO) { var questionItem = new QuestionItem { Id = questionItemDTO.Id, Question = questionItemDTO.Question, Options = questionItemDTO.Options, CorrectQuestion = questionItemDTO.CorrectQuestion, KnowMore = questionItemDTO.KnowMore, }; if (ModelState.IsValid) { context.QuestionItems.Add(questionItem); } else { return(BadRequest(ModelState)); } try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(CreatedAtAction( nameof(GetQuestionItem), new { id = questionItem.Id }, ItemToDTO(questionItem) )); }
public async Task<IActionResult> CreateQuestion([FromBody] CreateQuestionCmd cmd) { var dep = new QuestionDependencies(); var questions = await _dbContext.QuestionModel.ToListAsync(); var ctx = new QuestionWriteContext(questions); var expr = from CreateTenantResult in QuestionContext.CreateQuestion(cmd) select CreateTenantResult; var r = await _interpreter.Interpret(expr, ctx, dep); _dbContext.QuestionModel.Add(new DatabaseModel.Models.QuestionModel { Title = cmd.Title, Description = cmd.Description, Tags = cmd.Tags }); //var reply = await _dbContext.QuestionModel.Where(r => r.Title == "Intrebarea1").SingleOrDefaultAsync(); //_dbContext.QuestionModel.Update(reply); await _dbContext.SaveChangesAsync(); return r.Match( succ => (IActionResult)Ok(succ), fail => BadRequest("Reply could not be added") ); }
static void NonWorkingExample() { var input = PostOrder.ScoreDesc; var dbContext = new QuestionContext(); var users = dbContext.Users .Select(x => new { User = x, Top3Posts = x.Posts.AsQueryable() .OrderByCommon(input) .Take(3) .ToList() }).ToList(); foreach (var user in users) { Console.WriteLine($"User {user.User.FullName}"); Console.WriteLine($"Best posts:"); foreach (var post in user.Top3Posts) { Console.WriteLine($"Post {post.Title} with score {post.Score}"); } } }
// GET: Question/Update/id public ActionResult Update(int id) { try { using (var dataContext = new HuntingEntities()) { int languageId = (int)Session[LocalizationAttribute.SESSION_LANGUAGE_ID]; var user = AclUserContext.GetDetail(dataContext, User.Identity.Name); if (user == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Home")); } var question = QuestionContext.GetDetail(dataContext, id); if (question == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_FOUND); return(RedirectToAction("Index", "Home")); } if (user.CanUpdateTerritory(question.Questionnaire.MapItemType.Territory) == false) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Territory", new { id = question.Questionnaire.MapItemType.TerritoryId })); } var model = new QuestionUpdateModel(question); model.FillCodeList(languageId); return(View(model)); } } catch (Exception exception) { logger.Error(exception, "QuestionController"); ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Danger, GlobalRes.ERROR_EXCEPTION); return(RedirectToAction("Index", "Home")); } }
// GET: Question public ActionResult Index(int id) { try { using (var dataContext = new HuntingEntities()) { var user = AclUserContext.GetDetail(dataContext, User.Identity.Name); if (user == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Home")); } var questionnaire = QuestionnaireContext.GetDetail(dataContext, id); if (questionnaire == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_FOUND); return(RedirectToAction("Index", "Home")); } if (user.CanUpdateTerritory(questionnaire.MapItemType.Territory) == false) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Territory", new { id = questionnaire.MapItemType.TerritoryId })); } var itemList = QuestionContext.GetList(dataContext, questionnaire); var model = new QuestionListModel(questionnaire, itemList); return(View(model)); } } catch (Exception exception) { logger.Error(exception, "QuestionController"); ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Danger, GlobalRes.ERROR_EXCEPTION); return(RedirectToAction("Index", "Home")); } }
public QuestionController(QuestionContext context) { _context = context; }
public LeaderBoardController(QuestionContext context) { _context = context; }
public QuestionDB(QuestionContext context) { _context = context; }
public AnswerListViewComponent(QuestionContext questionContext, AnswerContext answerContext) { _questionContext = questionContext; _answerContext = answerContext; }
public HomeController(QuestionContext context) { this.context = context; }
public ImmersiveQuizAPI(CourseContext courseContext, LocationContext locationContext, QuestionContext questionContext, AnswerContext answerContext, ScoreContext scoreContext) { _courseContext = courseContext; _locationContext = locationContext; _questionContext = questionContext; _answerContext = answerContext; _scoreContext = scoreContext; }
public void CreateUser(User user) { QuestionContext.Users.Add(user); QuestionContext.SaveChanges(); }
private void WriteQuestion(QuestionContext context) { Content.WriteToConsole(context.NeedWarning ? ConsoleColor.Yellow : ConsoleColor.White); WriteDefaultAnswer(); Descriptions.WriteLinesToConsole(ConsoleColor.Gray); }
public DeleteQuestionHandler(QuestionContext context) { _context = context; }
public IndexModel(QuestionContext context) { _context = context; }
public QuestionRepository(QuestionContext questionContext, QuestionViewModel questionViewModel) { QuestionContext = questionContext; QuestionViewModel = questionViewModel; }
public void Create(Question question) { QuestionContext.Questions.Add(question); QuestionContext.SaveChanges(); }
public DBQuestionRepository() { _db = new QuestionContext(); }
public GameStateController(QuestionContext context) { _context = context; }
private bool QuestionItemExists( [FromServices] QuestionContext context, long id) { return(context.QuestionItems.Any(e => e.Id == id)); }
public AnswersController(AnswerContext context, QuestionContext questionContext, LocationContext locationContext) { _answerContext = context; _questionContext = questionContext; _locationContext = locationContext; }