示例#1
0
        // POST api/answer
        public AnswersDto Post(AnswersDto answers)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var id = Guid.NewGuid();
            answers.Id = id;

            if (!Answers.TryAdd(id, answers))
            {
                throw new HttpResponseException(HttpStatusCode.Conflict);
            }

            return answers;
        }
示例#2
0
        //
        // GET: /Answer/
        public ActionResult Get(Guid id)
        {
            var test = testApi.Get(id);
            var answers = new AnswersDto
                {
                    TestId = test.Id,
                    TestName = test.Name,
                    Answers =
                        test.Questions.Select(
                            q =>
                            new AnswerDto
                                {
                                    Question = q.Question,
                                    MarkingCriteria = q.MarkingCriteria,
                                    Points = q.Points
                                }).ToList(),
                };

            return View(answers);
        }