Exemplo n.º 1
0
 /// <summary>
 /// 获取单条数据
 /// </summary>
 /// <returns></returns>
 public V_xy_sp_chapter Get(Expression <Func <xy_sp_chapter, bool> > predicate = null)
 {
     using (xy_sp_chapterDAL dal = new xy_sp_chapterDAL()){
         xy_sp_chapter entity = dal.Get(predicate);
         return(EntityToModel(entity));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Edit(V_xy_sp_chapter model)
        {
            if (model == null)
            {
                return(false);
            }
            using (xy_sp_chapterDAL dal = new xy_sp_chapterDAL()){
                xy_sp_chapter entitys = ModelToEntity(model);

                return(dal.Edit(entitys));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string Add(V_xy_sp_chapter model)
        {
            if (model == null)
            {
                return(string.Empty);
            }

            using (xy_sp_chapterDAL dal = new xy_sp_chapterDAL()){
                xy_sp_chapter entity = ModelToEntity(model);
                entity.chapterID = string.IsNullOrEmpty(model.chapterID) ? Guid.NewGuid().ToString("N") : model.chapterID;

                return(dal.Add(entity));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Model转Entity
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private xy_sp_chapter ModelToEntity(V_xy_sp_chapter model)
        {
            if (model != null)
            {
                xy_sp_chapter entity = new xy_sp_chapter()
                {
                    chapterID       = model.chapterID,
                    chapterName     = model.chapterName,
                    chapterDescript = model.chapterDescript,
                    AddrID          = model.AddrID,
                };

                return(entity);
            }
            return(null);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Entity转Model
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private V_xy_sp_chapter  EntityToModel(xy_sp_chapter entity)
        {
            if (entity != null)
            {
                V_xy_sp_chapter model = new V_xy_sp_chapter()
                {
                    chapterID       = entity.chapterID,
                    chapterName     = entity.chapterName,
                    chapterDescript = entity.chapterDescript,
                    AddrID          = entity.AddrID,
                };

                return(model);
            }

            return(null);
        }