Esempio n. 1
0
        public JsonResult Create(CreateQuestionModel question)
        {
            var project = RavenSession.Load<Project>(question.ProjectId);

            var _question = new Question();

            if (question.Id > 0)
            {
                _question = project.Questions.FirstOrDefault(x => x.Id == question.Id);
                _question.Title = question.Title;
                _question.Answer = question.Answer;
            }
            else
            {

                _question = new Question()
                                    {
                                        Answer = question.Answer,
                                        Id = project.Questions.Count() + 1,
                                        Title = question.Title
                                    };
                project.Questions.Add(_question);
            }
            RavenSession.SaveChanges();

            return Json(new { Success = true, Question = _question });
        }
Esempio n. 2
0
        public JsonResult CreateQuestion(string projectId, Question question)
        {
            var project = RavenSession.Load<Project>(projectId);
            question.Id = project.Questions.Count() + 1;

            project.Questions.Add(question);

            RavenSession.SaveChanges();

            return Json(true);
        }