Beispiel #1
0
        public JsonResult ResetShopVersion(int shopsID, int shopVersionID)
        {
            //如果不是管理员,拒绝调用此方法
            if (!CurrentInfo.IsAdministrator)
            {
                return(Json(new Result(false, ResultType.Update), JsonRequestBehavior.AllowGet));
            }

            //这边要取出这个版本所有菜单,然后加到用户菜单关系表 和 商家菜单关系表中
            IRelationShopVersionModuleService relationShopVersionModuleService = ServiceFactory.Create <IRelationShopVersionModuleService>();
            var listModuleID = relationShopVersionModuleService.GetEntities(t => t.ShopVersionID == shopVersionID).Select(t => t.ModuleID).ToList();
            var strModuleID  = string.Join(",", listModuleID.ToArray());

            IShopsService  shopsService    = ServiceHelper.GetShopsService;
            IStoresService storesService   = ServiceHelper.GetStoresService;
            var            modelStore      = storesService.GetTopEntities(1, t => t.ID, t => t.ShopId == shopsID, true).FirstOrDefault();
            int            shopAdminUserID = shopsService.GetEntity(shopsID).AdminUserID;
            Role           roleModel       = ServiceHelper.GetRoleService.GetFirstOrDefault(t => t.StoreID == modelStore.ID);

            //添加商家和菜单的关系
            AddRelationShopModule(shopsID.ToString(), strModuleID);
            //添加门店和菜单的关系
            AddRelationStoreModule(modelStore.ID.ToString(), strModuleID);
            //添加用户和菜单的关系
            AddRelationUsersModule(shopAdminUserID.ToString(), strModuleID);

            //如果店家有添加角色
            if (roleModel != null)
            {
                //添加角色和菜单的关系
                AddRelationRoleModule(roleModel.ID.ToString(), strModuleID);
            }

            //System.Threading.Thread.Sleep(2000);

            return(Json(new Result(true, ResultType.Update), JsonRequestBehavior.AllowGet));
        }