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); }
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); }
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); }
public EditQuestionSectionViewModel(QuestionSection questionSection) { QuestionSection = questionSection; }
public ResponseModel Update(QuestionSection model) { return(_questionSectionRepository.Update(model)); }
public ResponseModel Insert(QuestionSection model) { return(_questionSectionRepository.Insert(model)); }
public EditQuestionSectionDialog(QuestionSection questionSection) : this(new EditQuestionSectionViewModel(questionSection)) { }