Exemplo n.º 1
0
        public ActionResult PermissionSetting(long ID)
        {
            IEnumerable <WorkV3.Models.SitesModels>    sites        = WorkV3.Models.DataAccess.SitesDAO.GetDatas();
            List <ViewModels.GroupPermissionViewModel> siteMenuList = new List <ViewModels.GroupPermissionViewModel>();

            foreach (WorkV3.Models.SitesModels site in sites)
            {
                siteMenuList.Add(new ViewModels.GroupPermissionViewModel {
                    SiteID = site.Id, menus = BackendMenuDAO.GetRoots(site.Id)
                });
            }

            long siteId = PageCache.SiteID;
            //IEnumerable<BackendMenuModel> rootMenu = BackendMenuDAO.GetRoots();
            //string jsonResult = JsonConvert.SerializeObject(siteMenuList);
            GroupModels group = GroupDAO.GetItem(ID, siteId);

            ViewBag.BodyClass = "body-admin-main";
            ViewBag.Group     = group;
            ViewBag.RootMenu  = siteMenuList;
            ViewBag.SiteID    = siteId;
            //ViewBag.RootMenuJson = jsonResult;
            ViewBag.WebUrl = System.Configuration.ConfigurationManager.AppSettings["WebUrl"].TrimEnd('/');

            return(View());
        }
Exemplo n.º 2
0
        // GET: Group/Edit/5
        public ActionResult Edit(int id)
        {
            try
            {
                GroupModels Group = new GroupModels();
                UserID = Session[CConfig.SESSION_USERID] == null ? 1 : Convert.ToInt32(Session[CConfig.SESSION_USERID]);

                Group = data.GetGroupByID(id);
                ViewData["ListRule"] = data.GetAccessRights(id);
                TempData["MenuList"] = new SelectList(data.GetListMenu(), "ID", "Name");
                TempData.Keep("MenuList");

                ViewData["ListGroupType"] = new SelectList(data.GetGroupTypeList(UserID), "ID", "NameVN", Group.GroupType);
                ViewData["Hotel"]         = new SelectList(dataNam.getListHotels(), "Code", "Name", Group.SysHotelCode);

                TempData["ListGroupMenu"] = data.GetListGroupMenu(id);
                TempData.Keep("ListGroupMenu");
                return(View(Group));
            }
            catch (Exception ex)
            {
                CLog.LogError(CBase.GetDeepCaller(), CBase.GetDetailError(ex));
                return(View());
            }
        }
Exemplo n.º 3
0
        public static int SetItems(List <GroupPermissionModels> permissions, long groupId, long siteId)
        {
            using (var conn = new SqlConnection(WebInfo.Conn))
            {
                GroupModels group = GroupDAO.GetItem(groupId, siteId);
                string      sql   = @" DELETE FROM GroupPermission WHERE GroupID = @GroupID AND PermissionType = @PermissionType ";
                Dictionary <string, object> param = new Dictionary <string, object>();
                param.Add("GroupID", groupId);
                param.Add("PermissionType", group.GroupType);

                conn.Execute(sql, param);
            }

            if (permissions == null)
            {
                return(0);
            }

            int retValue = 0;

            foreach (GroupPermissionModels permission in permissions)
            {
                retValue += SetItem(permission);
            }

            return(retValue);
        }
Exemplo n.º 4
0
        public static bool HaverPermission(long groupId, long siteId, int menuType, long menuId)
        {
            using (var conn = new SqlConnection(WebInfo.Conn))
            {
                GroupModels group = GroupDAO.GetItem(groupId, siteId);

                string sql = @" SELECT 1 FROM GroupPermission 
                                WHERE [GroupID] = @GroupID AND [SiteID] = @SiteID AND [MenuType] = @MenuType AND [MenuID] = @MenuID ";
                Dictionary <string, object> param = new Dictionary <string, object>();
                param.Add("@GroupID", groupId);
                param.Add("@SiteID", siteId);
                param.Add("@MenuType", menuType);
                param.Add("@MenuID", menuId);

                IEnumerable <GroupPermissionModels> permission = conn.Query <GroupPermissionModels>(sql, param);

                if (group.GroupType == 1) // 黑名單模式,找到的話 return false
                {
                    return(permission.Count() == 0 ? true : false);
                }
                else // 白名單模式,找到的話 return true
                {
                    return(permission.Count() == 0 ? false : true);
                }
            }
        }
Exemplo n.º 5
0
 public async Task <IHttpActionResult> Post([FromBody] GroupModels group)
 {
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         db.Group.Add(group);
         await db.SaveChangesAsync();
     }
     return(Ok());
 }
Exemplo n.º 6
0
        public ActionResult GroupSetting(long?ID = null)
        {
            GroupModels model = new GroupModels();

            ViewBag.BodyClass = "body-admin-main";
            if (ID.HasValue)
            {
                model = GroupDAO.GetItem((long)ID, PageCache.SiteID);
            }

            ViewBag.WebUrl = System.Configuration.ConfigurationManager.AppSettings["WebUpdUrl"].Replace("WebUPD", "").TrimEnd('/');
            return(View(model));
        }
Exemplo n.º 7
0
 public async Task <IHttpActionResult> Put(int id, [FromBody] GroupModels group)
 {
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         if (id != group.Id)
         {
             return(BadRequest());
         }
         db.Entry(group).State = EntityState.Modified;
         await db.SaveChangesAsync();
     }
     return(Ok());
 }
Exemplo n.º 8
0
        public ActionResult PermissionGroup_User(long ID)
        {
            List <MemberModels> GetMemberByGroup = GroupDAO.GetMemberByGroup(ID);

            string      GroupName = "";
            GroupModels GM        = GroupDAO.GetItem(ID);

            if (GM != null)
            {
                GroupName = GM.Name;
            }
            ViewBag.GroupName = GroupName;
            ViewBag.BodyClass = "body-admin-main";
            return(View(GetMemberByGroup));
        }
Exemplo n.º 9
0
        // GET: BackEnd
        public ActionResult Index(string SiteSN)
        {
            ViewBag.Member    = Session[WebInfo.SysMemSkey] == null ?null:(Request.Cookies["sessionId"] != null? MemberDAO.Current(Request.Cookies["sessionId"].Value): null);
            ViewBag.UploadUrl = uploadUrl;
            if (ViewBag.Member != null)
            {
                WorkV3.Models.SitesModels SiteItem = WorkV3.Models.DataAccess.SitesDAO.GetSiteInfo(SiteSN);
                if (SiteItem != null)
                {
                    MemberModels mem = MemberDAO.SysCurrent;

                    PageCache.SiteID   = SiteItem.Id;
                    PageCache.SiteName = SiteItem.Title;
                    ViewBag.SiteSN     = SiteSN;
                    ViewBag.SiteID     = PageCache.SiteID;
                    ViewBag.SiteName   = PageCache.SiteName;
                    List <MenusModels> mm = MenusDAO.GetData(PageCache.SiteID);

                    long                  siteId      = PageCache.SiteID;
                    List <Menu>           backendMenu = BackendMenuDAO.GetRoots(siteId).ToList();
                    List <CardsViewModel> cards       = CardsDAO.GetBySiteID(PageCache.SiteID);
                    MemberModels          curUser     = ViewBag.Member;
                    GroupModels           group       = ViewBag.Member == null ? new GroupModels() : GroupDAO.GetItem(curUser.GroupId, siteId);

                    ViewBag.MenuList    = mm;
                    ViewBag.Cards       = cards;
                    ViewBag.CardTypes   = CardsTypeDAO.GetData();
                    ViewBag.BackendMenu = backendMenu;
                    ViewBag.Permissions = group.GetPermissions(siteId);
                }
                else
                {
                    Response.Redirect(Url.Action("Sites"));
                }
                return(View());
            }
            else
            {
                Response.Redirect(Url.Action("Login"));
                return(View());
            }
        }
Exemplo n.º 10
0
 public ActionResult GroupSetting(GroupModels model)
 {
     GroupDAO.SetItem(model);
     ViewBag.Exit = true;
     return(View(model));
 }