Exemplo n.º 1
0
        /// <summary>
        /// 保存应用信息
        /// </summary>
        /// <param name="dbContext">上下文对象</param>
        /// <param name="dto">应用信息</param>
        /// <returns>是否成功</returns>
        protected virtual bool SaveApp(IBoundedContext dbContext, SYSAppRegistDTO dto)
        {
            if (!(dto.App.ID > 0))
            {
                InitApp(dto.App);
            }

            return(dto.App.ID.HasValue ? dbContext.Modify(dto.App) : dbContext.Add(dto.App));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存应用信息
        /// </summary>
        /// <param name="dto">应用信息</param>
        /// <returns>是否成功</returns>
        public virtual bool SaveApp(SYSAppRegistDTO dto)
        {
            using (var dbContext = BoundedContext.Create())
            {
                if (!(SaveApp(dbContext, dto) &&
                      SaveMenu(dbContext, dto) &&
                      SaveAppAccess(dbContext, dto)))
                {
                    return(false);
                }

                dbContext.Commit();
                return(true);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存应用用户组关联信息
        /// </summary>
        /// <param name="dbContext">上下文对象</param>
        /// <param name="dto">应用信息</param>
        /// <returns>是否成功</returns>
        protected virtual bool SaveAppAccess(IBoundedContext dbContext, SYSAppRegistDTO dto)
        {
            var result    = true;
            var appAccess = dbContext.Repository <SYSAppAccess>();

            if (dto.App.ID > 0)
            {
                appAccess.Remove(new Spec <SYSAppAccess>(d => d.AppID == dto.App.ID));
            }

            if (dto.AppGroups != null)
            {
                foreach (var appAccessInfo in dto.AppGroups)
                {
                    appAccessInfo.AppID = dto.App.ID; if (!(result = appAccess.Add(appAccessInfo)))
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 保存应用菜单信息
        /// </summary>
        /// <param name="dbContext">上下文对象</param>
        /// <param name="dto">应用信息</param>
        /// <returns>是否成功</returns>
        protected virtual bool SaveMenu(IBoundedContext dbContext, SYSAppRegistDTO dto)
        {
            var menu = dbContext.Repository <SYSMenu>();

            var q = from d in menu.Entities
                    where d.AppID == dto.App.ID &&
                    d.Layer == 0
                    select d;

            var target = q.FirstOrDefault();

            if (target != null)
            {
                dto.Menu.Map(target);
            }
            else
            {
                target = dto.Menu;
            }

            InitMenu(dto.App, target);

            return(target.ID > 0 ? menu.Modify(target) : menu.Add(target));
        }