Exemple #1
0
        // **************************************
        // URL: /Account/QuestionAndAnswer
        // **************************************
        public ActionResult QuestionAndAnswer(string userName)
        {
            if (!Membership.EnablePasswordReset)
            {
                ModelState.AddModelError("", ErrorCodeToString(AccountCreateStatus.PasswordResetDisabled));
                return(View());
            }

            MembershipUser user = Membership.GetUser(userName);

            if (user == null)
            {
                ModelState.AddModelError("", ErrorCodeToString(AccountCreateStatus.InvalidUserName));
                return(View());
            }
            else
            {
                ViewData["UserName"] = userName;
                ViewData["Question"] = Membership.GetUser(userName).PasswordQuestion;

                QuestionAndAnswerModel model = new QuestionAndAnswerModel();
                model.UserName         = userName;
                model.PasswordQuestion = Membership.GetUser(userName).PasswordQuestion;

                return(View(model));
            }
        }
Exemple #2
0
        public ActionResult New(QuestionAndAnswerModel model)
        {
            //TODO: Return partial view "Entry" with an instance of QuestionAndAnswerModel.
            //If model is valid then persists the new entry on DB. Make sure  data changes are committed.

            try
            {
                if (ModelState.IsValid)
                {
                    //QuestionAndAnswerModel qAA = AutoMapper.Mapper.Map<QuestionAndAnswerModel>(this.KnowledgeBaseQuery.Get(downCast.Id));

                    KnowledgeBaseItem newItem = new KnowledgeBaseItem
                    {
                        Query        = model.Question,
                        Answer       = model.Answer,
                        LastUpdateOn = DateTime.Now,
                        Tags         = model.Tags
                    };
                    this.KnowledgeBaseData.Add(newItem);
                    this.KnowledgeBaseData.CommitChanges();
                }

                return(PartialView(model));
            }
            catch {
                throw new Exception();
            }
        }
        public ActionResult QuestionAndAnswer()
        {
            var questions = QuestionSelectListItems;

            var model = new QuestionAndAnswerModel()
            {
                Questions = new SelectList(questions, "Text", "Value")
            };

            return(View(model));
        }
Exemple #4
0
 public void Setup()
 {
     _decisionMaker = new DecisionMaker(pathSettings)
     {
         //Path = "../../../Dialogs.json"
     };
     qaModel = new QuestionAndAnswerModel()
     {
         Answers = new List <string> {
             ".net", "1-2 hours", "novice"
         },
         QuestionModel = new QuestionModel()
     };
 }
        public ActionResult New(QuestionAndAnswerModel model)
        {
            //TODO: Return partial view "Index" to reload the page.
            //If model is valid then persists the new entry on DB. Make sure  data changes are committed.
            if (ModelState.IsValid)
            {
                var entity = mapper.Map <KnowledgeBaseItem>(model);
                KnowledgeBaseData.Add(entity);
                KnowledgeBaseData.CommitChanges();

                return(RedirectToAction("Index"));
            }
            return(Index());
        }
        public ActionResult QuestionAndAnswer(QuestionAndAnswerModel model)
        {
            if (ModelState.IsValid)
            {
                if (MembershipService.ChangeQuestionAndAnswer(_currentUser.UserName, model.Password, model.Question, model.Answer))
                {
                    return(View("QuestionAndAnswerSuccess"));
                }

                ModelState.AddModelError("Password", "Incorrect password provided. Please try again.");
            }

            model.Questions = new SelectList(QuestionSelectListItems, "Text", "Value");

            return(View(model));
        }
        public void New_ValidQuestion()
        {
            var inputModel = new QuestionAndAnswerModel()
            {
                Question = "Question1", Answer = "Answer1", Tags = "Tag1, Tag2"
            };

            dataService.Setup(x => x.Add(It.IsAny <KnowledgeBaseItem>()));

            var controller = new HomeController(logger.Object, dataService.Object, queryService.Object);
            var viewResult = controller.New(inputModel);

            Assert.IsNotNull(viewResult);
            Assert.IsInstanceOfType(viewResult, typeof(RedirectToActionResult));
            Assert.AreEqual((viewResult as RedirectToActionResult).ActionName, "Index");
        }
Exemple #8
0
        public ActionResult New(QuestionAndAnswerModel model)
        {
            //If model is valid then persists the new entry on DB. Make sure  data changes are committed.

            if (ModelState.IsValid)
            {
                KnowledgeBaseData.Add(new KnowledgeBaseItem
                {
                    Answer = model.Answer,
                    Tags   = model.Tags
                });
                model.Answer   = string.Empty;
                model.Question = string.Empty;
                model.Tags     = string.Empty;
                KnowledgeBaseData.CommitChanges();
            }

            return(PartialView("~/Shared/Entry", model as QuestionAndAnswerModel));
        }
Exemple #9
0
        public void New_ValidQuestion()
        {
            var inputModel = new QuestionAndAnswerModel()
            {
                Question = "Question1", Answer = "Answer1", Tags = "Tag1, Tag2"
            };

            dataService.Setup(x => x.Add(It.IsAny <KnowledgeBaseItem>()));

            var controller = new Wispero.Web.Controllers.HomeController(dataService.Object, queryService.Object);
            var viewResult = controller.New(inputModel);

            Assert.IsNotNull(viewResult);
            Assert.IsInstanceOfType(viewResult, typeof(PartialViewResult));

            var model = ((PartialViewResult)viewResult).Model as Models.QuestionAndAnswerModel;

            Assert.IsTrue(string.IsNullOrEmpty(model.Answer) && string.IsNullOrEmpty(model.Question) && string.IsNullOrEmpty(model.Tags));
        }
Exemple #10
0
        public ActionResult QuestionAndAnswer(QuestionAndAnswerModel model, string userName, string PasswordQuestion, string PasswordAnswer)
        {
            if (ModelState.IsValid)
            {
                RegisterPasswordSuccessModel rpsModel = new RegisterPasswordSuccessModel();
                rpsModel = ResetPassword(userName, PasswordAnswer, GetLoginUrl());

                if (rpsModel.RegisterPasswordSuccess)
                {
                    return(RedirectToAction("PasswordResetFinal", new { userName = userName }));
                }
                else
                {
                    ModelState.AddModelError("", rpsModel.ErrorMessage);
                    return(View(model));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemple #11
0
        public void New_QuestionIncomplete()
        {
            var inputModel = new QuestionAndAnswerModel()
            {
                Question = "Question1", Answer = null, Tags = "Tag1, Tag2"
            };

            dataService.Setup(x => x.Add(It.IsAny <KnowledgeBaseItem>()));

            var controller = new Wispero.Web.Controllers.HomeController(dataService.Object, queryService.Object);

            controller.ModelState.AddModelError("Answer", "Answer is required");

            var viewResult = controller.New(inputModel);

            Assert.IsNotNull(viewResult);
            Assert.IsInstanceOfType(viewResult, typeof(PartialViewResult));

            var model = ((PartialViewResult)viewResult).Model as Models.QuestionAndAnswerModel;

            Assert.AreEqual(inputModel, model);
        }
Exemple #12
0
        public ActionResult Entry()
        {
            QuestionAndAnswerModel model = new QuestionAndAnswerModel();

            return(PartialView("~/Shared/Entry", model));
        }
Exemple #13
0
        /// <summary>
        /// conversations with users which subscribed to notifications
        /// TODO: possible renaming needed
        /// </summary>
        //private readonly ConcurrentDictionary<string, ConversationReference> _conversationReferences;


        public MainDialog(UserState state, IStatePropertyAccessor <DialogInfo> dialogInfoStateProperty,
                          IConfiguration configuration, IDecisionMaker decisionMaker,
                          ISubscriptionManager subscriptionManager, IEmailSender emailSender,
                          ThreadedLogger Logger,
                            //ConcurrentDictionary<string, ConversationReference> conversationReferences,
                          StuddyBotContext db
                          ) // DialogInfo dialogInfo, StuddyBotContext db
            : base(nameof(MainDialog), dialogInfoStateProperty, Logger)
        {
            Configuration = configuration;
            this._Logger  = Logger;
            DecisionMaker = decisionMaker;
            EmailSender   = emailSender;
            //_conversationReferences = conversationReferences;

            _QuestionAndAnswerModel = new QuestionAndAnswerModel();
            _QuestionAndAnswerModel.QuestionModel           = new QuestionModel();
            _QuestionAndAnswerModel.QuestionModel.Questions = new List <Question>();
            _QuestionAndAnswerModel.QuestionModel.Decisions = new List <DecisionModel>();
            _QuestionAndAnswerModel.Answers = new List <string>();
            _DecisionModel = new DecisionModel();
            //_DialogInfo = new DialogInfo(); //dialogInfo;
            _dialogInfoStateProperty = dialogInfoStateProperty; //state.CreateProperty<DialogInfo>(nameof(DialogInfo));
            //_DialogInfo = _dialogInfoState.GetAsync();

            _db = db;

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));

            AddDialog(new LanguageDialog(_dialogInfoStateProperty, DecisionMaker, subscriptionManager, _Logger,
                                         EmailSender, db, Configuration));
            AddDialog(new LocationDialog(_dialogInfoStateProperty, DecisionMaker, subscriptionManager, _Logger,

                                         EmailSender, db));

            AddDialog(new MailingDialog(_dialogInfoStateProperty, DecisionMaker, emailSender, subscriptionManager,
                                        _Logger, db));


            AddDialog(new EmailDialog(_dialogInfoStateProperty, decisionMaker, subscriptionManager, emailSender,
                                      Logger,
                                      //_DialogInfo,
                                      //conversationReferences,
                                      db
                                      ));
            AddDialog(new HelpDialog(_dialogInfoStateProperty, DecisionMaker, subscriptionManager, _Logger,

                                     EmailSender, db));

            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                StartLanguageDialogAsync
            }));


            StartServices();

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }