Пример #1
0
        /// <summary>
        /// 添加字典
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task Add(DictionaryAddRequest info)
        {
            using (_db)
            {
                Domain.Dictionary model = _mapper.Map <Domain.Dictionary>(info);
                if (info.PId != null)
                {
                    Domain.Dictionary pModel = await _db.Dictionary.FindByIdAsync(info.PId.ToInt());

                    model.Category = pModel.Category;
                    model.Name     = pModel.Name;
                }
                await _db.AddEntityAsync(model);

                await _db.SaveChangesAsync();
            }
        }
Пример #2
0
        /// <summary>
        /// 添加模块
        /// </summary>
        public async Task Add(ModuleAddRequest info)
        {
            if (info.PId == null)
            {
                if (info.Type == (int)ModuleTypeEnum.Menu)
                {
                    throw new ApiException("顶级目录类型不能为菜单!");
                }
            }
            using (_db)
            {
                Module model = _mapper.Map <Module>(info);
                await _db.AddEntityAsync(model);

                await _db.SaveChangesAsync();
            }
        }