Exemplo n.º 1
0
        public QuestionKit GetById(int id)
        {
            QuestionKit result = new QuestionKit();

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

                try
                {
                    conn.Open();

                    result = conn.Query <QuestionKit>(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);
        }
Exemplo n.º 2
0
        public ResponseModel Update(QuestionKit model)
        {
            var result = new ResponseModel();

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

                    questionKit.Name        = model.Name;
                    questionKit.Description = model.Description;
                    questionKit.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);
        }
Exemplo n.º 3
0
        public QuestionKitModel(QuestionKit questionKit)
        {
            ID          = questionKit.ID;
            Name        = questionKit.Name;
            Description = questionKit.Description;

            RecordOrder  = questionKit.RecordOrder;
            Created      = questionKit.Created;
            CreatedBy    = questionKit.CreatedBy;
            LastUpdate   = questionKit.LastUpdate;
            LastUpdateBy = questionKit.LastUpdateBy;
        }
Exemplo n.º 4
0
        public ResponseModel Insert(QuestionKit model)
        {
            var result = new ResponseModel();

            using (var db = new KentEntities())
            {
                try
                {
                    db.QuestionKits.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);
        }
Exemplo n.º 5
0
 public ResponseModel Update(QuestionKit model)
 {
     return(_questionKitRepository.Update(model));
 }
Exemplo n.º 6
0
 public ResponseModel Insert(QuestionKit model)
 {
     return(_questionKitRepository.Insert(model));
 }