Exemple #1
0
        /// <summary>
        /// 更新数据字典
        /// </summary>
        /// <param name="group"></param>
        /// <param name="items"></param>
        /// <returns></returns>
        public List <DataDictionary> Update(DataDictionaryGroup group, List <DataDictionary> items)
        {
            if (group == null)
            {
                throw new Exception("数据字典分组不能为null");
            }
            ISqlMapper             mapper   = MapperHelper.GetMapper();
            DataDictionaryGroupDao groupdao = new DataDictionaryGroupDao(mapper);
            DataDictionaryDao      dicdao   = new DataDictionaryDao(mapper);

            groupdao.Update(new DataDictionaryGroupUpdateForm {
                Entity = group,
                DataDictionaryGroupQueryForm = new DataDictionaryGroupQueryForm
                {
                    ID = group.ID,
                }
            });
            if (items != null)
            {
                foreach (var item in items)
                {
                    if (string.IsNullOrEmpty(item.ID))
                    {
                        dicdao.Add(item);
                    }
                    else
                    {
                        var dic = dicdao.Query(new DataDictionaryQueryForm {
                            ID = item.ID
                        });
                        if (dic == null)
                        {
                            dicdao.Add(item);
                        }
                        else
                        {
                            dicdao.Update(new DataDictionaryUpdateForm
                            {
                                Entity = item,
                                DataDictionaryQueryForm = new DataDictionaryQueryForm
                                {
                                    ID = item.ID,
                                }
                            });
                        }
                    }
                }
            }
            return(items);
        }
        public void Init()
        {
            Cleanup();
            DataDictionaryGroupDao groupdao = new DataDictionaryGroupDao();
            DataDictionaryDao      datadao  = new DataDictionaryDao();

            groupdao.Add(new DataDictionaryGroup
            {
                ID             = "1",
                Name           = "unittest1",
                LastUpdateTime = DateTime.Now,
            });
            groupdao.Add(new DataDictionaryGroup
            {
                ID             = "2",
                Name           = "unittest2",
                LastUpdateTime = DateTime.Now,
            });

            datadao.Add(new DataDictionary
            {
                ID = "1",
                DataDictionaryGroupID = "1",
                Name  = "unittest1",
                Value = 1,
            });

            datadao.Add(new DataDictionary
            {
                ID = "2",
                DataDictionaryGroupID = "1",
                Name  = "unittest2",
                Value = 2,
            });
            datadao.Add(new DataDictionary
            {
                ID = "3",
                DataDictionaryGroupID = "2",
                Name  = "unittest3",
                Value = 1,
            });
        }
 /// <summary>
 /// 新增数据字典明细
 /// </summary>
 /// <param name="items"></param>
 /// <returns>返回数据组回传加上了id</returns>
 public List<DataDictionary> AddItems(List<DataDictionary> items)
 {
     ISqlMapper mapper = MapperHelper.GetMapper();
     DataDictionaryDao dicdao = new DataDictionaryDao(mapper);
     if (items != null)
     {
         foreach (var item in items)
         {
             dicdao.Add(item);
         }
     }
     return items;
 }
Exemple #4
0
        /// <summary>
        /// 新增数据字典明细
        /// </summary>
        /// <param name="items"></param>
        /// <returns>返回数据组回传加上了id</returns>
        public List <DataDictionary> AddItems(List <DataDictionary> items)
        {
            ISqlMapper        mapper = MapperHelper.GetMapper();
            DataDictionaryDao dicdao = new DataDictionaryDao(mapper);

            if (items != null)
            {
                foreach (var item in items)
                {
                    dicdao.Add(item);
                }
            }
            return(items);
        }
 /// <summary>
 /// 新增数据字典明细
 /// </summary>
 /// <param name="items"></param>
 /// <returns>返回数据组回传加上了id</returns>
 public List<DataDictionary> AddItems(List<DataDictionary> items)
 {
     if (items == null) throw new Exception("数据字典项不能为null");
     ISqlMapper mapper = MapperHelper.GetMapper();
     DataDictionaryDao dicdao = new DataDictionaryDao(mapper);
     if (items != null)
     {
         foreach (var item in items)
         {
             dicdao.Add(item);
         }
     }
     return items;
 }
 /// <summary>
 /// 更新数据字典
 /// </summary>
 /// <param name="group"></param>
 /// <param name="items"></param>
 /// <returns></returns>
 public List<DataDictionary> Update(DataDictionaryGroup group, List<DataDictionary> items)
 {
     if (group == null) throw new Exception("数据字典分组不能为null");
     ISqlMapper mapper = MapperHelper.GetMapper();
     DataDictionaryGroupDao groupdao = new DataDictionaryGroupDao(mapper);
     DataDictionaryDao dicdao = new DataDictionaryDao(mapper);
     groupdao.Update(new DataDictionaryGroupUpdateForm
     {
         Entity = group,
         DataDictionaryGroupQueryForm = new DataDictionaryGroupQueryForm
         {
             ID = group.ID,
         }
     });
     if (items != null)
     {
         foreach (var item in items)
         {
             if (string.IsNullOrEmpty(item.ID))  dicdao.Add(item);
             else
             {
                 var dic = dicdao.Query(new DataDictionaryQueryForm { ID = item.ID });
                 if (dic == null) dicdao.Add(item);
                 else
                 {
                     dicdao.Update(new DataDictionaryUpdateForm
                     {
                         Entity = item,
                         DataDictionaryQueryForm = new DataDictionaryQueryForm
                         {
                             ID = item.ID,
                         }
                     });
                 }
             }
         }
     }
     return items;
 }
        public void Init()
        {
            Cleanup();
            DataDictionaryGroupDao groupdao = new DataDictionaryGroupDao();
            DataDictionaryDao datadao = new DataDictionaryDao();
            groupdao.Add(new DataDictionaryGroup
            {
                ID = "1",
                Name = "unittest1",
                LastUpdateTime = DateTime.Now,
            });
            groupdao.Add(new DataDictionaryGroup
            {
                ID = "2",
                Name = "unittest2",
                LastUpdateTime = DateTime.Now,
            });

            datadao.Add(new DataDictionary
            {
                ID = "1",
                DataDictionaryGroupID = "1",
                Name = "unittest1",
                Value = 1,
            });

            datadao.Add(new DataDictionary
            {
                ID = "2",
                DataDictionaryGroupID = "1",
                Name = "unittest2",
                Value = 2,
            });
            datadao.Add(new DataDictionary
            {
                ID = "3",
                DataDictionaryGroupID = "2",
                Name = "unittest3",
                Value = 1,
            });
        }