public IList<string> GetUserRights() { IList<string> rights = new List<string>(); using (Entities dbContext = new Entities()) { rights = dbContext.Users.Find(this.UserId).UserLevel.UserRights.Select(r => r.Name).ToList(); } return rights; }
public static string GetDbSetting(string key, bool fallback = true) { Entities dbContext = new Entities(); var setting = dbContext.Settings.FirstOrDefault(s => s.Name == key); if (setting != null) { return setting.Value; } else { if(fallback) { return Util.GetAppSetting(key); } } return null; }
public static User GetUserById(int userId) { try { Entities dbContext = new Entities(); User user = dbContext.Users.Find(userId); return user; } catch (EntityException ex) { throw ex; } }
public static User GetLoggedInUser() { try { string username = System.Web.HttpContext.Current.User.Identity.Name; Entities dbContext = new Entities(); var user = dbContext.Users.FirstOrDefault(u => u.Username == username); return user; } catch(Exception ex) { throw ex; } }