示例#1
0
        public ActionResult Sample(string sample)
        {
            UpdateList();
            SurveyViewModel s = listSurvey.Find(l => l.Title == "Sample");

            if (s != null)
            {
                IsPreview      = false;
                ViewBag.Survey = s.Id;
                AccountController.RememberSurvey(s);
                AccountController.RememberSurveyId(s.Id);
            }
            return(RedirectToAction("Index"));
        }
示例#2
0
 public ActionResult TemporaryEdit(SurveyViewModel surveyViewModel)
 {
     if (ModelState.IsValid)
     {
         surveyViewModel.UpdateSurvey(surveyViewModel);
         AccountController.RememberSurvey(surveyViewModel);
         ViewBag.SurveyTypeId = new SelectList(listSurveyType, "Id", "Type", surveyViewModel.SurveyTypeId);
         ViewBag.UserId       = new SelectList(listUser, "Id", "Username", surveyViewModel.UserId);
         return(RedirectToAction("Create", "Surveys", new { surveyViewModel = surveyViewModel }));
     }
     UpdateList();
     ViewBag.SurveyTypeId = new SelectList(listSurveyType, "Id", "Type", surveyViewModel.SurveyTypeId);
     ViewBag.UserId       = new SelectList(listUser, "Id", "Username", surveyViewModel.UserId);
     return(View(surveyViewModel));
 }
示例#3
0
 // GET: Surveys/Edit/5
 public ActionResult Edit(Guid?id)
 {
     if (AccountController.CheckPermission("Survey-Edit"))
     {
         AccountController.RememberSurveyId((Guid)id);
         AccountController.RememberSession("Edit", "true");
         UpdateList();
         AccountController.RememberSurvey(listSurvey.Find(x => x.Id == id));
         return(RedirectToAction("Create"));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
示例#4
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));
        }