Пример #1
0
        public ResponseModel Update(QuestionSection model)
        {
            var result = new ResponseModel();

            using (var db = new KentEntities())
            {
                try
                {
                    var questionSection = db.QuestionSections.Where(d => d.ID == model.ID).FirstOrDefault();
                    if (questionSection == null)
                    {
                        return(result);
                    }

                    questionSection.Description   = model.Description;
                    questionSection.SectionType   = model.SectionType;
                    questionSection.QuestionKitID = model.QuestionKitID;
                    questionSection.LastUpdate    = DateTime.Now;

                    result.Success = db.SaveChanges() > 0 ? true : false;
                }
                catch (SqlException sqlEx)
                {
                    result.Message = sqlEx.Message;
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    Logger.ErrorException(ex);
                }
            }

            return(result);
        }
Пример #2
0
        public QuestionSection GetById(int id)
        {
            QuestionSection result = new QuestionSection();

            using (IDbConnection conn = Connection)
            {
                string sql = "select * from QuestionSections where Id = {0}";
                sql = string.Format(sql, id);

                try
                {
                    conn.Open();

                    result = conn.Query <QuestionSection>(sql).AsQueryable().FirstOrDefault();
                }
                catch (SqlException sqlEx)
                {
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(ex);
                }
                finally
                {
                    if (conn != null && conn.State != ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                }
            }

            return(result);
        }
Пример #3
0
        public ResponseModel Insert(QuestionSection model)
        {
            var result = new ResponseModel();

            using (var db = new KentEntities())
            {
                try
                {
                    db.QuestionSections.Add(model);
                    result.Success = db.SaveChanges() > 0 ? true : false;
                }
                catch (SqlException sqlEx)
                {
                    result.Message = sqlEx.Message;
                    Logger.ErrorException(sqlEx);
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    Logger.ErrorException(ex);
                }
            }
            return(result);
        }
Пример #4
0
 public EditQuestionSectionViewModel(QuestionSection questionSection)
 {
     QuestionSection = questionSection;
 }
Пример #5
0
 public ResponseModel Update(QuestionSection model)
 {
     return(_questionSectionRepository.Update(model));
 }
Пример #6
0
 public ResponseModel Insert(QuestionSection model)
 {
     return(_questionSectionRepository.Insert(model));
 }
 public EditQuestionSectionDialog(QuestionSection questionSection)
     : this(new EditQuestionSectionViewModel(questionSection))
 {
 }