Esempio n. 1
0
        public ActionResult Create(InsertQuestionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                vm.Question.TitleUrl = vm.Question.Title.ToUrlFriendly();
                vm.Question.PostedById = CurrentUser.UserInfo.Id;

                var feedback = _qRepo.InsertQuestion(vm.Question);

                if (feedback.Success)
                {
                    return RedirectToAction("Details", new { id = feedback.Data.Id, questionTitleUrl = feedback.Data.TitleUrl });
                }
                SetMessage(feedback.Message, MessageType.Error);
            }

            return View(vm);
        }
Esempio n. 2
0
        public ViewResult Edit(int id)
        {
            InsertQuestionViewModel vm = null;
            var feedback = _qRepo.GetQuestionForEditing(id);
            if (feedback.Success)
            {
                if (feedback.Data.PostedById != CurrentUser.UserInfo.Id && !SecurityHelper.CanEditContentsDirectly())
                {
                    SetMessage(Messages.EditQuestion_NotAllowed, MessageType.Error);
                    return View(vm);
                }

                vm = new InsertQuestionViewModel
                {
                    Question = feedback.Data,
                };
                return View(vm);
            }
            SetMessage(feedback.Message, MessageType.Error);
            return View(vm);
        }