public void InitializeDb()
 {
     var initializer = new DropCreateDatabaseIfModelChanges<SurveyorContext>();
       using (var db = new SurveyorContext())
       {
     initializer.InitializeDatabase(db);
     DbSeeder.Seed(db);
     db.SaveChanges();
       }
 }
        public ActionResult SurveyResponses(int id)
        {
            IEnumerable<SurveyResponse> responses = null;

              using (var db = new SurveyorContext())
              {
            responses = db.Responses.Include(r => r.Respondent).Where(r => r.SurveyId == id).ToList();
            ViewBag.Survey = db.Surveys.Single(s => s.Id == id);
              }

              return View(responses);
        }
        public void ResponsesContainsRespondent()
        {
            using (var db = new SurveyorContext())
              {
            var respondent = db.Respondents.First();
            var survey = db.Surveys.First();
            var response1 = new SurveyResponse() { RespondentId = respondent.Id, SurveyId = survey.Id };
            db.Responses.Add(response1);
            db.SaveChanges();
              }

              using (var db = new SurveyorContext())
              {
            var response = db.Responses.Include(r => r.Respondent).First();
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Respondent);
            Assert.IsNotNull(response.Respondent.UserName);
              }
        }
 public ViewResult Index()
 {
     using (var db = new SurveyorContext())
       {
     var model = db.Responses.Include(r => r.Respondent).Include(r => r.Survey).ToList();
     return View(model);
       }
 }