Example #1
0
        /// <summary>
        /// Metod koj vrzi azuriranje na vidlivite funkcii za specificiran korisnik
        /// so novo definirani funkcii dadeni kako string-ovi
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="newFunctionsNames"></param>
        public static void UpdateVisibleFunctions(int userId, HashSet <string> newFunctionsNames)
        {
            HashSet <string>    oldFunctions = GetVisibleFunctionsByUser(userId);
            List <UsersWebPage> forInsert    = new List <UsersWebPage>();
            List <UsersWebPage> forDelete    = new List <UsersWebPage>();

            foreach (string f in newFunctionsNames)
            {
                if (!oldFunctions.Contains(f))
                {
                    UsersWebPage uPage = new UsersWebPage();
                    uPage.UserID    = userId;
                    uPage.WebPageID = WebPage.GetWebPageByFunctionName(f).ID;
                    forInsert.Add(uPage);
                }
            }

            foreach (string f in oldFunctions)
            {
                if (!newFunctionsNames.Contains(f))
                {
                    UsersWebPage uPage = new UsersWebPage();
                    uPage.UserID    = userId;
                    uPage.WebPageID = WebPage.GetWebPageByFunctionName(f).ID;
                    forDelete.Add(uPage);
                }
            }
            UsersWebPage.DeleteUserWebPages(forDelete);
            UsersWebPage.InsertUserWebPages(forInsert);
        }
Example #2
0
        public static void SetVisibleWebPages(int userID, int roleID)
        {
            List <Broker.DataAccess.Function> functions = Broker.DataAccess.Role.GetFucntionsByRole(roleID).ToList();
            List <UsersWebPage> userPages = new List <UsersWebPage>();

            foreach (Broker.DataAccess.Function f in functions)
            {
                UsersWebPage uPage   = new UsersWebPage();
                WebPage      webPage = WebPage.GetWebPageByFunction(f);
                uPage.UserID    = userID;
                uPage.WebPageID = webPage.ID;
                userPages.Add(uPage);
            }
            UsersWebPage.InsertUserWebPages(userPages);
        }
Example #3
0
        /// <summary>
        /// Metod za dozvolenite privilegii za pregled na specificirano url na
        /// web-strana za specificiraniot korisnik
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="relativeUrl"></param>
        /// <returns>bool</returns>
        public static bool IsUserPrivileged(int userId, string relativeUrl)
        {
            WebPage page = WebPage.GetWebPageByUrl(relativeUrl);

            return(UsersWebPage.EntityExists(userId, page.ID));
        }
Example #4
0
 /// <summary>
 /// Metod koj gi vraka vidlivite web-strani za specificiran korisnik
 /// </summary>
 /// <param name="userId"></param>
 /// <returns>numerirana lista - IEnumerable(UsersWebPage)</returns>
 public static IEnumerable <UsersWebPage> GetVisibleWebPagesByUser(int userId)
 {
     return(UsersWebPage.GetVisibleWebPagesByUser(userId));
 }