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")); }
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)); }
// 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")); } }
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)); }