public ActionResult Edit(SurveyQuestion surveyquestion) { try { if (Session["UserAccountID"] == null) { return(RedirectToAction("Validate", "Login")); } User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) { ViewData["txtIsAdmin"] = "true"; } else { ViewData["txtIsAdmin"] = "false"; } if (ModelState.IsValid) { string validation = ValidateInput(surveyquestion); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; return(View(surveyquestion)); } repository.UpdateSurveyQuestion(surveyquestion); CommonMethods.CreateActivityLog((User)Session["User"], "SurveyQuestion", "Edit", "Edited survey question '" + surveyquestion.SurveyQuestionText + "' - ID: " + surveyquestion.SurveyQuestionID.ToString()); return(RedirectToAction("Edit", "Survey", new { id = surveyquestion.SurveyID })); } return(View(surveyquestion)); } catch (Exception ex) { Helpers.SetupApplicationError("SurveyQuestion", "Edit POST", ex.Message); return(RedirectToAction("Index", "ApplicationError")); } }
public Survey CreateSurvey(List <int> surveyQuestions, List <Grade> surveyAnswers, int appointmentId) { if (!CheckIfExistsById(appointmentId)) { return(null); } Survey survey = new Survey(); survey.AppointmentId = appointmentId; survey.Date = DateTime.Now; survey.SurveyQuestions = surveyQuestions; survey.SurveyAnswers = surveyAnswers; Survey createdSurvey = surveyRepository.Create(survey); bool update = surveyQuestionRepository.UpdateSurveyQuestion(createdSurvey); if (!update) { return(null); } return(createdSurvey); }