Exemplo n.º 1
0
        /// <summary>
        /// 根据主键集合删除字典目录
        /// </summary>
        /// <param name="Ids">待删除的字典目录主键集合</param>
        /// <returns></returns>
        public OperationResult DeleteDataItems(params Guid[] Ids)
        {
            DataItemRepository.UnitOfWork.BeginTransaction();
            int count = 0;

            foreach (var id in Ids)
            {
                var result = DataItemRepository.Entities.FirstOrDefault(m => m.Id == id);
                if (result != null)
                {
                    if (result.IsSystem)
                    {
                        throw new Exception($"id:系统预设的字典不能被删除");
                    }
                    count += DataItemRepository.DeleteDirect(id);
                }
            }
            DataItemRepository.UnitOfWork.Commit();
            if (count > 0)
            {
                return(new OperationResult(OperationResultType.Success, $"id:成功删除了{count}条数据"));
            }
            else
            {
                return(new OperationResult());
            }
        }
Exemplo n.º 2
0
        public void TestCacheKeyIsNotGeneric_Member_Property()
        {
            IRepository <DataItem> repository = new DataItemRepository();
            var cache = new Simple.FluentDictionaryCache().WithSource(repository);
            var strat = cache.Method(c => c.Default);

            Assert.IsFalse(strat.Region.Contains("IRepository`1"), "The region should be based on the concrete type DataItemRepository and not the calling type in the expression IRepository<DataItem>");
        }
Exemplo n.º 3
0
 /// <summary>
 /// 编辑字典目录
 /// </summary>
 /// <param name="datas">待更新的字典目录</param>
 /// <returns></returns>
 public OperationResult EditDataItems(params DataItemInputDto[] datas) => DataItemRepository.Update(datas,
                                                                                                    checkAction: (dto, entity) =>
 {
     if (dto.QueryCoding != entity.QueryCoding && entity.IsSystem)
     {
         throw new Exception("id:系统预设的字典目录查询码不允许修改!");
     }
 },
                                                                                                    updateFunc: (dto, entity) =>
 {
     return(entity);
 });
Exemplo n.º 4
0
 public BaseWorkArea(CoreDbContext context) : base(context)
 {
     User         = new UserRepository(context);
     Permission   = new PermissionRepository(context);
     UserAddress  = new UserAddressRepository(context);
     Media        = new MediaRespository(context);
     DataItem     = new DataItemRepository(context);
     Setting      = new SettingRepository(context);
     UrlSlug      = new UrlSlugRepository(context);
     District     = new DistrictRepository(context);
     SiteSettings = new SiteSettingsRepository(context);
     SiteHost     = new SiteHostRepository(context);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 添加字典数据目录
 /// </summary>
 /// <param name="datas">待添加的数据集合</param>
 /// <returns></returns>
 public OperationResult AddDataItems(params DataItemInputDto[] datas) => DataItemRepository.Insert(datas,
                                                                                                   checkAction: dto =>
 {
     if (DataItemRepository.CheckExists(b => b.QueryCoding == dto.QueryCoding && b.FullName == dto.FullName))
     {
         throw new Exception($"id:字典:{dto.FullName}&{dto.QueryCoding}参数已经存在,请不要重复添加!");
     }
 },
                                                                                                   updateFunc: (dto, entity) =>
 {
     entity.CreatedTime = DateTime.Now;
     entity.IsSystem    = false;
     return(entity);
 });
Exemplo n.º 6
0
 public DataItemController(IConfiguration configuration)
 {
     this._repository = new DataItemRepository(configuration);
 }