コード例 #1
0
        public async Task <object> AddQuestion([FromBody] AddQuestionViewModel addQuestionViewModel)
        {
            bool   result = true;
            string error  = string.Empty;

            Conversation conversation = new Conversation();

            addQuestionViewModel.Timestamp = DateTimeOffset.Now;

            try
            {
                conversation = _conversationRepository.AddQuestion(addQuestionViewModel.DoctorId, addQuestionViewModel.PatientId, addQuestionViewModel.Title, addQuestionViewModel.Message, 1, 0, false, addQuestionViewModel.Timestamp);
            }
            catch (Exception ex)
            {
                result = false;
                error  = ex.Message;
            }

            return(new SingleResponse <Conversation>
            {
                Message = error,
                DidError = !result,
                ErrorMessage = error,
                Token = string.Empty,
                Model = conversation,
            });
        }
コード例 #2
0
        public IActionResult AddQuestion(AddQuestionViewModel model)
        {
            var _user = new AuthenticateResponse
            {
                MembershipKey = 1006979,                   //1007435,
                EmailAddress  = "*****@*****.**", //"*****@*****.**",
                FirstName     = "Tolulope",
                LastName      = "Olusakin",
                FullName      = "Olusakin Tolulope S"//"Funmilayo Ruth Adeyemi",
            };

            try
            {
                if (!ModelState.IsValid)
                {
                    ViewBag.message = "Error! Incorrect form details.";
                    return(View(model));
                }

                var armSeqRequest = new ArmOneSecurityQuestionRequest
                {
                    UserId            = _user.EmailAddress,
                    SecurityQuestion  = model.NewQuestion,
                    SecurityQuestion2 = String.Empty,
                    SecurityAnswer    = model.NewAnswer,
                    SecurityAnswer2   = String.Empty,
                    Channel           = "Client_Portal"
                };
                var armSeqResponse = _clientService.ArmOneSecurityQuestion(armSeqRequest);

                var cpRequest = new AddSecurityQuestionRequest
                {
                    MembershipNumber = _user.MembershipKey,
                    SecurityQuestion = model.NewQuestion,
                    SecurityAnswer   = model.NewAnswer
                };
                var cpResponse = _clientService.AddSecurityQuestion(cpRequest);

                var armoneres = (armSeqResponse != null && (armSeqResponse.ResponseCode == "00")) ? true : false;
                var cpres     = (cpResponse != null && (cpResponse.Status == "00" || cpResponse.Status == "0")) ? true : false;

                if (cpres && armoneres)
                {
                    _user.SecurityQuestion = model.NewQuestion;
                    var msg = "Success: " + cpResponse.StatusMessage;
                    ViewBag.message = msg;
                }
                else
                {
                    ViewBag.message = cpResponse.StatusMessage;
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                Utilities.ProcessError(ex, _contentRootPath);
                _logger.LogError(null, ex, ex.Message);
            }
            return(View(model));
        }
コード例 #3
0
ファイル: TestController.cs プロジェクト: artoyebi/ExamPortal
        public IActionResult AddQuestion(AddQuestionViewModel model)
        {
            //var findTest = testRepository.FindTest(testId);
            //if (findTest == null)
            //{
            //    return View("NotFound");
            //}

            if (ModelState.IsValid)
            {
                QuestionAndAnswer questionAndAnswer = new QuestionAndAnswer
                {
                    Id            = Guid.NewGuid(),
                    Question      = model.Question,
                    Answer        = model.Answer,
                    Option1       = model.Option1,
                    Option2       = model.Option2,
                    Option3       = model.Option3,
                    AssignedScore = model.AssignedScore,
                    TestId        = model.TestId
                };

                testRepository.AddQuestions(questionAndAnswer);

                return(RedirectToAction("dashboard", "examiner"));
            }
            return(View(model));
        }
コード例 #4
0
        public virtual async Task <ActionResult> Create(AddQuestionViewModel viewModel)
        {
            // if ((viewModel.Type == QuestionType.CheckBoxList || viewModel.Type == QuestionType.RadioButtonList) && viewModel.Options == null)
            {
                this.AddErrors("Title", "برای سوال از نوع چند گزینه ای لازم است گزنیه درج کنید");
            }
            if (!ModelState.IsValid)
            {
                return(new JsonNetResult
                {
                    Data = new
                    {
                        success = false,
                        View = this.RenderPartialViewToString(MVC.Question.Views._Create, viewModel)
                    }
                });
            }
            var newQuestion = await _questionService.CreateAsync(viewModel);

            return(new JsonNetResult
            {
                Data = new
                {
                    success = true,
                    View = this.RenderPartialViewToString(MVC.Question.Views._QuestionItem, newQuestion)
                }
            });
        }
コード例 #5
0
        public AddQuestion()
        {
            AddQuestionViewModel context = new AddQuestionViewModel();

            context.Pop        += () => Navigation.PopAsync();
            this.BindingContext = context;
            InitializeComponent();
        }
コード例 #6
0
        public IActionResult Questions(int id)
        {
            AddQuestionViewModel model = new AddQuestionViewModel();

            model.Survey    = _surveyService.GetSurveyById(id);
            model.Questions = _surveyService.GetSurveyQuestions(id);
            return(View(model));
        }
コード例 #7
0
        public AddQuestion()
        {
            AddQuestionViewModel context = new AddQuestionViewModel();

            //Register to the event so the view model will be able to navigate to the monkeypage
            context.NavigateToPageEvent += NavigateToAsync;
            this.BindingContext          = context;
            InitializeComponent();
        }
コード例 #8
0
        public IActionResult CreateQuestion()
        {
            AddQuestionViewModel model = new AddQuestionViewModel
            {
                categories = _categoryService.GetAll()
            };

            return(View(model));
        }
コード例 #9
0
        public IActionResult Index()
        {
            AddQuestionViewModel model = new AddQuestionViewModel()
            {
                Themes = _questionManager.GetThemes(),
                Quizs  = _questionManager.GetQuizs()
            };

            return(View(model));
        }
コード例 #10
0
 public Questions(AddQuestionViewModel model)
 {
     QuestionId = Guid.NewGuid();
     Name       = model.Name;
     ImageUri   = model.ImageUri;
     FirstHint  = model.FirstHint;
     Info       = model.Info;
     Latitude   = model.Latitude;
     Longitude  = model.Longitude;
     SecondHint = model.SecondHint;
 }
コード例 #11
0
        public ActionResult AddQuestions(int ClassId, int ExamId)
        {
            var usermanager          = IdentityTools.NewUserManager();
            var uid                  = usermanager.FindByName(User.Identity.Name);
            AddQuestionViewModel aqm = new AddQuestionViewModel();

            aqm.Questions = QrRepo.GetAll(q => q.IsDeleted == false && q.ExamId == ExamId).ToList();
            aqm.ExamId    = ExamId;
            aqm.ClassId   = ClassId;
            return(View(aqm));
        }
コード例 #12
0
        //نظر سنجی
        public async Task <IActionResult> Questions()
        {
            var getAll = await _db.QuestionsRepository.GetAllAsync();

            var viewmodel = new AddQuestionViewModel()
            {
                Question = getAll,
            };

            return(View(viewmodel));
        }
コード例 #13
0
        public IActionResult AddQuestion([FromBody] AddQuestionViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _quizService.AddQuestion(viewModel);
            _quizService.AddAnswers(viewModel.Answers, viewModel.Question);

            return(Ok());
        }
コード例 #14
0
 public ActionResult AddQuestion(AddQuestionViewModel addQuestionViewModel)
 {
     using (var context = new surveyEntities())
     {
         QuestionTable questionTable = new QuestionTable();
         questionTable.Question  = addQuestionViewModel.Question;
         questionTable.Survey_ID = addQuestionViewModel.Survey_ID;
         context.QuestionTables.Add(questionTable);
         context.SaveChanges();
     }
     return(View());
 }
コード例 #15
0
 public IActionResult CreateQuestion(AddQuestionViewModel model)
 {
     if (ModelState.IsValid)
     {
         var userId = _userManager.GetUserId(HttpContext.User);
         model.Soru.UserId = userId;
         _soruService.SoruEkle(model.Soru);
         TempData["message2"] = "Sorunuz başarıyla oluşturuldu";
         return(RedirectToAction("Index", "Home"));
     }
     return(View(model));
 }
コード例 #16
0
        public async Task <QuestionViewModel> CreateAsync(AddQuestionViewModel viewModel)
        {
            var question = _mappingEngine.Map <Question>(viewModel);

            foreach (var option in viewModel.Options)
            {
                question.AnswerOptions.Add(_mappingEngine.Map <AnswerOption>(option));
            }
            _questions.Add(question);
            await _unitOfWork.SaveChangesAsync();

            return(await GetQuestionViewModel(question.Id));
        }
コード例 #17
0
        public IActionResult AddQuestion(AddQuestionViewModel model)
        {
            bool isQuestionAdded = surveyRepository.IsQuestionAdded(model);

            if (isQuestionAdded)
            {
                ViewBag.QuestionAdded = "The URL has been Added";
                return(View());
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Could not able to add URL");
            }
            return(View());
        }
コード例 #18
0
        public bool IsQuestionAdded(AddQuestionViewModel model)
        {
            Question question = new Question();

            question.Q_Text = model.UrlText;
            var res = surveyDBContext.Questions.Add(question);

            surveyDBContext.SaveChanges();

            if (res == null)
            {
                return(false);
            }

            return(true);
        }
コード例 #19
0
        public IActionResult AddQuestion(AddQuestionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var question = new Question
                {
                    QuestionName = model.QuestionName,
                    True         = model.True,
                    False        = model.False
                };
                _context.Add(question);
                _context.SaveChanges();

                return(RedirectToAction("Questions", "Administrator"));
            }
            return(View(model));
        }
コード例 #20
0
        public ActionResult CreateQuestion(int GameID)
        {
            if (CheckLoggedIn())
            {
                return(RedirectToAction("Index", "Login"));
            }

            AddQuestionViewModel model = new AddQuestionViewModel();

            model.Game     = gameHandler.GetGame(GameID);
            model.Question = new Question();
            model.Question.ImageQuestion                  = new Models.QuestionModels.ImageQuestion();
            model.Question.MultipleChoiseQuestion         = new Models.QuestionModels.MultipleChoiseQuestion();
            model.Question.MultipleChoiseQuestion.Answers = new List <string>();

            return(View(model));
        }
コード例 #21
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var date         = DateTime.Now.ToPersianDateString();
            var question     = _db.QuestionsRepository.Where(p => p.StartThePoll <= Convert.ToDateTime(date) && p.EndThePoll >= Convert.ToDateTime(date)).Take(1).ToList();
            var btnQuestions = await _db.BtnQuestionRepository.GetAllAsync();

            foreach (var item in btnQuestions)
            {
                item.UserAnswer = _db.UserAnswerRepository.Where(p => p.BtnQuestionId == item.Id);
            }
            var viewModel = new AddQuestionViewModel()
            {
                Question    = question,
                BtnQuestion = btnQuestions
            };

            return((IViewComponentResult)View("Question", viewModel));
        }
コード例 #22
0
ファイル: AdviceController.cs プロジェクト: liphis/BabyDev
        public ActionResult Ask(AddQuestionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userId   = this.GetUserId();
                var question = new Question
                {
                    Title    = model.Title,
                    Body     = model.Body,
                    AuthorId = userId
                };

                this.Data.Questions.Add(question);
                this.Data.SaveChanges();
                return(this.RedirectToAction("Details", new { id = question.Id }));
            }
            return(this.View(model));
        }
コード例 #23
0
        public ActionResult Add(AddQuestionViewModel question)
        {
            if (!ModelState.IsValid)
            {
                return(View(question));
            }

            var success = this.admins.SaveQuestion(question.Text, question.CorrectAnswer, question.FirstWrongAnswer, question.SecondWrongAnswer,
                                                   question.ThirdWrongAnswer, question.QuestionNumber);

            if (!success)
            {
                this.TempData.AddErrorMessage("Your question adding was unsuccessfull");
            }

            this.TempData.AddSuccessMessage("You've successfully added question to the game");

            return(RedirectToAction(nameof(Add)));
        }
コード例 #24
0
        public IActionResult ProcessAddQuestionForm(AddQuestionViewModel addQuestionViewModel)
        {
            if (ModelState.IsValid)
            {
                Question newQuestion = new Question
                {
                    Prompt             = addQuestionViewModel.Prompt,
                    ImgRelatedToPrompt = addQuestionViewModel.ImgRelatedToPrompt,
                    Type    = addQuestionViewModel.Type,
                    Answer  = addQuestionViewModel.Answer,
                    Options = addQuestionViewModel.Options
                };
                context.Questions.Add(newQuestion);
                context.SaveChanges();

                return(Redirect("Question"));
            }

            return(View("Add", addQuestionViewModel));
        }
コード例 #25
0
        public async Task <IActionResult> AddBtnQuestions(AddQuestionViewModel model, string questionId)
        {
            if (model.BtnQuestion.Any())
            {
                foreach (var item in model.BtnQuestion)
                {
                    var btnQuedtion = new BtnQuestion()
                    {
                        Name        = item.Name,
                        QuestionId  = questionId,
                        CreatedTime = DateTime.Now,
                    };
                    await _db.BtnQuestionRepository.InsertAsync(btnQuedtion);
                }
                await _db.SaveChangeAsync();

                _notification.AddSuccessToastMessage("با موفقیت دکمه ها به سوال اضافه شد");
                return(Redirect("/Admin/Offers/Questions"));
            }
            return(View());
        }
コード例 #26
0
 public IActionResult EditQuestion(AddQuestionViewModel model)
 {
     model.Signs         = _signService.GetTypesSigns("");
     model.Question.Sign = _signService.GetSign(model.Question.Sign.ID);
     if (model.Question.Variants.Count < 2 || model.Question.Variants.Count > 5)
     {
         ModelState.AddModelError("Question.Variants", "Количество вариантов должно быть от 2 до 5");
         return(View(model));
     }
     if (string.IsNullOrEmpty(model.Question.Text))
     {
         ModelState.AddModelError("Question.Text", "Введите текст вопроса");
         return(View(model));
     }
     if (!(model.Question.ForKids || model.Question.ForBikers || model.Question.ForDrivers || model.Question.ForPedestrians))
     {
         ModelState.AddModelError("Question.ForKids", "Выберите хотя бы один из типов.");
         return(View(model));
     }
     _questService.EditQuestion(model.Question);
     return(RedirectToAction("ManageQuestions", "Admin"));
 }
コード例 #27
0
        public async Task <JsonResult> AddQuestion(string doctorId, string patientId, string title, string message)
        {
            AddQuestionViewModel addQuestionViewModel = new AddQuestionViewModel();

            addQuestionViewModel.DoctorId  = doctorId;
            addQuestionViewModel.PatientId = patientId;
            addQuestionViewModel.Title     = title;
            addQuestionViewModel.Message   = message;

            string response = await APICallerExtensions.APICallAsync("Question/AddQuestion", addQuestionViewModel, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

            if (response.ToLower().Contains("exception:"))
            {
                return(Json(new
                {
                    result = false,
                    error = response
                }));
            }
            var content = JsonConvert.DeserializeObject <SingleResponse <Conversation> >(response);

            if (!content.DidError)
            {
                return(Json(new
                {
                    result = true,
                    conversation = content.Model
                }));
            }
            else
            {
                return(Json(new
                {
                    result = false,
                    error = content.Message
                }));
            }
        }
コード例 #28
0
 public static void ClearAddQuestion()
 {
     _addQuestion = null;
 }
コード例 #29
0
 private static void CreateAddQuestion()
 {
     if (_addQuestion == null)
     {
         _addQuestion = new AddQuestionViewModel();
     }
 }
コード例 #30
0
 public void Post([FromBody] AddQuestionViewModel model)
 {
     _questionRepository.Insert(model);
 }
コード例 #31
0
 public void AddQuestion(AddQuestionViewModel viewModel)
 {
     _questionManager.AddQuestion(viewModel.Question, viewModel.Theme, viewModel.Quiz);
 }
コード例 #32
0
        public async Task <IActionResult> AddQuestion([FromBody] AddQuestionViewModel question)
        {
            if (!ModelState.IsValid)
            {
                return(new BadResponseResult(ModelState));
            }
            Logger.LogInformation($"{nameof(QuestionsController)}.{nameof(AddQuestion)}.Start");
            string externalUrl;

            if (!question.BackgroundUrl.IsNullOrEmpty())
            {
                if (MediaConverter.IsStandardBackground(question.BackgroundUrl))
                {
                    externalUrl = await Hub.Media.UploadBackgroundUrl(BackgroundType.Standard, question.BackgroundUrl);
                }
                else
                {
                    externalUrl = await Hub.Media.UploadBackgroundUrl(BackgroundType.Custom, question.BackgroundUrl);
                }
            }
            else
            {
                var urls = await Hub.Media.GetStandardBackgroundsUrl(BackgroundSizeType.Original);

                externalUrl = urls.Count < 1 ? null : urls[Random.Next(urls.Count)];
            }

            var questionId = await MainDb.Questions.AddQuestion(question.UserId, question.Condition, externalUrl,
                                                                question.AudienceType, question.QuestionType, question.IsAnonymous, question.FirstOption,
                                                                question.SecondOption);

            var badAddedTags = new List <string>();

            question.Tags = question.Tags.Select(x => x.Trim().ToUpper()).ToList();

            for (var i = 0; i < question.Tags.Count; i++)
            {
                var tag = question.Tags[i];
                if (!await MainDb.Tags.AddTag(questionId, tag, i))
                {
                    badAddedTags.Add(tag);
                }
            }

            var notFoundIds = new List <int>();

            // var validIds = await _mainDb.UserQuestions.CheckIdsValid(question.RecommendedToIds);

            if (question.RecommendedToIds == null)
            {
                question.RecommendedToIds = new List <int>();
            }

            if (question.Tags == null)
            {
                question.Tags = new List <string>();
            }

            foreach (var id in question.RecommendedToIds)
            {
                if (!await MainDb.UserQuestions.AddRecommendedQuestion(id, question.UserId, questionId))
                {
                    await Hub.Notifications.SendRecommendQuestionNotification(question.UserId, id, questionId, DateTime.UtcNow);
                }
                else
                {
                    notFoundIds.Add(id);
                }
            }
            Logger.LogInformation($"{nameof(QuestionsController)}.{nameof(AddQuestion)}.End");

            if (badAddedTags.Count != 0)
            {
                return(new ResponseResult((int)HttpStatusCode.InternalServerError, "Not all tags were inserted.",
                                          new { NotAddedTags = badAddedTags }));
            }
            return(new OkResponseResult(new { QuestionId = questionId }));
        }