예제 #1
0
        public ActionResult Create([Bind(Include = "Id,SurveyTypeId,Title,UserId,UserName,Description,SurveyType,IsBlock,IsDeleted,ModifiedDate,ModifiedUserId,DeletionDate,DeletionUserId,CreatedDate,CreatedUserId")] SurveyViewModel surveyViewModel, string CreateSurvey)
        {
            QuestionsController q = new QuestionsController();

            if (ModelState.IsValid)
            {
                if (CreateSurvey == "Create Survey")
                {
                    surveyViewModel.Id     = Guid.NewGuid();
                    surveyViewModel.UserId = AccountController.GetUser().Id;
                    surveyViewModel.AddSurvey(surveyViewModel);
                    AccountController.RememberSurveyId(surveyViewModel.Id);
                    UpdateList();
                    AccountController.RememberSurvey(listSurvey.Find(x => x.Id == surveyViewModel.Id));
                    AccountController.ClearCount();

                    ViewBag.SurveyTypeId = new SelectList(listSurveyType, "Id", "Type");
                    ViewBag.UserId       = new SelectList(listUser, "Id", "Username");

                    ViewBag.QuestionTypeId = new SelectList(q.GetQuestionType(), "Id", "Type");
                    return(View(surveyViewModel));
                }
                else if (CreateSurvey == "Edit Survey")
                {
                    SurveyViewModel s = AccountController.GetSurvey();
                    s.Title          = surveyViewModel.Title;
                    s.Description    = surveyViewModel.Description;
                    s.SurveyTypeId   = surveyViewModel.SurveyTypeId;
                    s.ModifiedUserId = AccountController.GetUser().Id;
                    TemporaryEdit(s);
                }
            }
            UpdateList();
            ViewBag.QuestionTypeId = new SelectList(q.GetQuestionType(), "Id", "Type");
            ViewBag.SurveyTypeId   = new SelectList(listSurveyType, "Id", "Type");
            ViewBag.UserId         = new SelectList(listUser, "Id", "Username");
            return(View(surveyViewModel));
        }
예제 #2
0
        // GET: Surveys/Create
        public ActionResult Create(string error)
        {
            if (AccountController.CheckPermission("Survey-Create"))
            {
                if (error != null)
                {
                    ModelState.AddModelError("Questions", error);
                }
                UpdateList();
                System.Web.HttpContext.Current.Session["action"] = "Survey-Create";
                if (AccountController.CheckSession("Edit"))
                {
                    ViewBag.edit = true;
                    AccountController.ClearSession("Edit");
                }
                else
                {
                    ViewBag.edit = false;
                }
                ViewBag.SurveyTypeId = new SelectList(listSurveyType, "Id", "Type");
                ViewBag.UserId       = new SelectList(listUser, "Id", "Username");

                QuestionsController q = new QuestionsController();
                ViewBag.QuestionTypeId = new SelectList(q.GetQuestionType(), "Id", "Type");


                if (AccountController.CheckSurveyId())
                {
                    return(View(AccountController.GetSurvey()));
                }

                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }