コード例 #1
0
        public virtual bool Create(ref ValidationErrors errors, DEF_TestCaseRelationModel model)
        {
            try
            {
			    DEF_TestCaseRelation entity = m_Rep.GetById(model.PCode);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return false;
                }
                entity = new DEF_TestCaseRelation(); 
				entity.PCode = model.PCode;
				entity.CCode = model.CCode;
				entity.ReMark = model.ReMark;
				entity.Sort = model.Sort;
  

                if (m_Rep.Create(entity))
                {
                    return true;
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return false;
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return false;
            }
        }
コード例 #2
0
        public virtual bool Edit(ref ValidationErrors errors, DEF_TestCaseRelationModel model)
        {
            try
            {
                DEF_TestCaseRelation entity = m_Rep.GetById(model.PCode);
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return false;
                }
                              				entity.PCode = model.PCode;
				entity.CCode = model.CCode;
				entity.ReMark = model.ReMark;
				entity.Sort = model.Sort;
 


                if (m_Rep.Edit(entity))
                {
                    return true;
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return false;
                }

            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return false;
            }
        }
コード例 #3
0
        //根据主键获取模型
        public DEF_TestCaseRelationModel GetModelById(string pcode, string ccode)
        {
            var entity = m_Rep.GetById(pcode, ccode);

            if (entity == null)
            {
                return(null);
            }
            DEF_TestCaseRelationModel model = new DEF_TestCaseRelationModel();

            //实现对象到模型转换
            model.PCode  = entity.PCode;
            model.CCode  = entity.CCode;
            model.ReMark = entity.ReMark;

            return(model);
        }
コード例 #4
0
        public virtual DEF_TestCaseRelationModel GetById(string id)
        {
            if (IsExists(id))
            {
                DEF_TestCaseRelation entity = m_Rep.GetById(id);
                DEF_TestCaseRelationModel model = new DEF_TestCaseRelationModel();
                              				model.PCode = entity.PCode;
				model.CCode = entity.CCode;
				model.ReMark = entity.ReMark;
				model.Sort = entity.Sort;
 
                return model;
            }
            else
            {
                return null;
            }
        }