public JsonResult AskQuestion(AskQuestionModel model) { var message = string.Format("Пишет {0}\nТема: {1}\nВопрос: {2}\nEmail: {3}\nТелефон: {4}", model.Name, model.Subject, model.Message, model.Email, model.Tel); TelegramBot.SendMessage(message); return(new JsonResult()); }
public ActionResult AskQuestion(AskQuestionModel model) { Mapper.CreateMap <AskQuestionModel, Question>().ReverseMap(); var question = Mapper.Map <AskQuestionModel, Question>(model); var context = new OverflowVictorContext(); question.Owner = Guid.Parse(HttpContext.User.Identity.Name); context.Questions.Add(question); context.SaveChanges(); return(RedirectToAction("Index", "Question")); }
public async Task <IActionResult> Ask(Guid id, [FromBody] AskQuestionModel question) { try { var game = await _store.GetGame(id); if (game.IsComplete) { return(BadRequest("This game has ended")); } if (game.QuestionsTaken >= game.TotalQuestions) { return(BadRequest("No more questions allowed")); } if (!game.AllowConcurrentQuestions && game.Questions.Count > 0 && !game.Questions.Last().HasAnswer) { return(BadRequest("Only one question allowed at a time")); } var questionModel = new QuestionModel { Question = question.Question }; game.Questions.Add(questionModel); await _store.UpdateGame(game); var response = game.ToResponseModel(); await GameHub.SendUpdate(_clients, id, response); return(Ok(response)); } catch (NotFoundException) { return(NotFound()); } }
public IActionResult Ask(AskQuestionModel askQuestionModel) { if (!ModelState.IsValid) { return(View(askQuestionModel)); } Question q = new Question(); q.DateCreated = DateTime.Now; q.Title = askQuestionModel.Title; q.Description = askQuestionModel.Content; q.UserId = 1; _dbContext.Questions.Add(q); _dbContext.SaveChanges(); ModelState.Clear(); ViewBag.SuccessMessage = "Data was saved"; return(View()); // return RedirectToAction("Index"); }
public IActionResult Ask(AskQuestionModel askQuestionModel) { //TODO: Save the question in the database return(RedirectToAction("Index")); }