public HttpResponseMessage Post(Guid surveyId, SurveySubmission submission)
        {
            var survey = this.surveyRepository.Get(surveyId);

            if (survey == null)
            {
                throw this.WebException(HttpStatusCode.NotFound);
            }

            var surveySubmission = new SurveySubmission
            {
                Survey = survey
            };

            submission.Answers.ToList().ForEach(
                a =>
                {
                    var question = survey.Questions.FirstOrDefault(q => q.Id == a.Question.Id);
                    if (question != null)
                    {
                        surveySubmission.Answers.Add(
                            new SurveyAnswer
                            {
                                Value = a.Value,
                                Question = question
                            });
                    }
                });

            var addedSurveySubmission = this.surveyRepository.InsertSurveySubmission(surveySubmission);

            // Notify Submission to SignalR clients
            var hubContext = GlobalHost.ConnectionManager.GetHubContext<SurveyHub>();
            if (hubContext.Clients != null)
            {
                var answers = this.submissionSummaryService.GetSubmissionsSummary(surveyId);
                hubContext.Clients.updateSurveyResults(new { SurveyId = surveyId, GroupedAnswers = answers });
            }

            // Response Message
            var response = this.Request.CreateResponse<SurveySubmission>(HttpStatusCode.Created, addedSurveySubmission);
            var surveyUri = Url.Link("SubmissionsApi", new { SurveyId = surveyId, SubmissionId = addedSurveySubmission.Id });
            response.Headers.Location = new Uri(surveyUri);

            return response;
        }
        public SurveySubmission InsertSurveySubmission(SurveySubmission surveySubmission)
        {
            if (surveySubmission == null)
            {
                throw new ArgumentNullException("surveySubmission", "Parameter surveySubmission cannot be null.");
            }

            var addedSurveySubmission = this.surveyContext.SurveySubmissions.Add(surveySubmission);
            this.surveyContext.SaveChanges();

            return addedSurveySubmission;
        }