示例#1
0
        public ActionResult AddSurvey(SurveyModel model)
        {
            if (ModelState.IsValid)
            {
                var survey = new Survey(model.Title);
                Context.AddSurvey(survey);

                Context.SaveChanges();
            }

            return JsonView(ModelState.IsValid, "_AddSurvey", model);
        }
示例#2
0
        public ActionResult Edit(SurveyModel model)
        {
            if (ModelState.IsValid)
            {
                Survey survey;
                if (!Context.Surveys.TryGetById(model.Id, out survey))
                    throw new InvalidOperationException(string.Format("survey with id {0} was not found", model.Id));

                survey.Title = model.Title;
                Context.SaveChanges();
            }

            return View("EditSurvey", model);
        }
示例#3
0
        public ActionResult Edit(long id)
        {
            Survey survey;
            if (!Context.Surveys.TryGetById(id, out survey))
                throw new InvalidOperationException(string.Format("survey with id {0} was not found", id));

            var model = new SurveyModel
            {
                Id = survey.Id,
                Title = survey.Title,
                Active = survey.Active
            };

            return View("EditSurvey", model);
        }