Esempio n. 1
0
 public void Update(Models.Survey.SurveyModel survey)
 {
     try
     {
         db.Entry(survey).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         Log.Error(ex.Message, ex);
     }
 }
Esempio n. 2
0
        public long Save(Models.Survey.SurveyModel survey)
        {
            try
            {
                db.SurveyModels.Add(survey);
                db.SaveChanges();

                return(survey.SurveyID);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                return(-1);
            }
        }
Esempio n. 3
0
        public void Delete(Models.Survey.SurveyModel survey)
        {
            try
            {
                db.Database.ExecuteSqlCommand("DELETE FROM SurveyParameters WHERE SurveyModel_SurveyID = {0}",
                                              new object[] { survey.SurveyID });

                foreach (var surveyInstance in survey.SurveyInstances)
                {
                    db.Database.ExecuteSqlCommand("DELETE FROM SurveyKeyValues WHERE SurveyInstance_SurveyInstanceID = {0}",
                                                  new object[] { surveyInstance.SurveyInstanceID });
                }


                db.SurveyModels.Remove(survey);
                db.SaveChanges();

                db.Database.ExecuteSqlCommand("DELETE FROM SurveyInstances WHERE SurveyModel_SurveyID IS NULL");
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
            }
        }