/// <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); }
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); }
/// <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)); }
/// <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)); }