Exemplo n.º 1
0
 public List<SurveryEF.Survey> GetAllSurveys()
 {
     using (var dbContext = new NICS_SurveyEntities1())
     {
         var surveys = dbContext.Surveys;
         List<SurveryEF.Survey> s = new List<SurveryEF.Survey>(surveys);
         return s;
     }
 }
Exemplo n.º 2
0
        public SurveryEF.Survey GetSurveyById(int surveyId)
        {
            using (var dbContext = new NICS_SurveyEntities1())
            {

                var query = from p in dbContext.Surveys
                            where p.SurveyID == surveyId
                            select p;

                return query.SingleOrDefault();
            }
        }
Exemplo n.º 3
0
        public bool SaveAnswer(Answer answer)
        {
            var ctx = HttpContext.Current;

            var newAnswers = new SurveryEF.Answer
            {
                AnswerID = 1,
                AnswerText = "Test database insert",
                NextQuestionID = 2,
                QuestionID = 1
            };

            //create DBContext object
            using (var dbContext = new NICS_SurveyEntities1())
            {
                //Add Student object into Students DBset
                dbContext.Answers.Add(newAnswers);

                // call SaveChanges method to save student into database
                dbContext.SaveChanges();
            }

            return true;
        }
Exemplo n.º 4
0
        public bool SaveSurvey(string survey)
        {
            var newSurvey = new SurveryEF.Survey
            {
                SurveyID = 23,
                SurveyCreatorID = 1,
                SurveyStartDate = System.DateTime.Now,
                SurveyEndDate = System.DateTime.Now.AddDays(10),
                SurveyTitle = survey,
                SurveyStartSummary = "Welcome to Scrum Team 7",
                SurveyEndSummary = "Thank you for taking Scrum Team 7's awesome survey"
            };

            //create DBContext object
            using (var dbContext = new NICS_SurveyEntities1())
            {
                //Add Student object into Students DBset
                dbContext.Surveys.Add(newSurvey);

                // call SaveChanges method to save student into database
                dbContext.SaveChanges();
            }

            return true;
        }