public virtual ActionResult Index(string id, SurveyResultViewModel model)
        {
            var count = Results.GetResults(CurrentResource, CurrentUser).Count;

            if (CurrentResource.MaxTimes.HasValue && count > CurrentResource.MaxTimes)
            {
                return(View("Unavailable", AvailabilityResult.No("This survey can only be taken " + CurrentResource.MaxTimes + " times.")));
            }

            // score the Survey
            var result = CurrentResource.Score(CurrentUser, model.Answers);

            // possibly award points
            if (result.PointsEarned.HasValue && result.PointsEarned > 0)
            {
                var tx = TryAwardPoints(result.PointsEarned.Value);
                if (null != tx)
                {
                    result.Transaction = tx.Document.Id;
                }
            }
            Results.Save(result);

            // show the review screen
            return(RedirectToAction(MVC.Site.Survey.Review(id, result.Document.Id)));
        }
        public virtual ActionResult Index(string id)
        {
            var count = Results.GetResults(CurrentResource, CurrentUser).Count;

            if (CurrentResource.MaxTimes.HasValue && count > CurrentResource.MaxTimes)
            {
                return(View("Unavailable", AvailabilityResult.No("This survey can only be taken " + CurrentResource.MaxTimes + " times.")));
            }
            return(View(SurveyViewModel.FromDomain(CurrentResource)));
        }