using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace EnVisage.Models.Cache { public class User { public Guid Id { get; set; } public bool PreferredResourceAllocation { get; set; } public bool PreferredTotalsDisplaying { get; set; } public List Roles { get; set; } public string GetPreferences(string pageUrl, string dataSection) { string result = String.Empty; using (EnVisageEntities dbContext = new EnVisageEntities()) { var prefRecords = dbContext.UserPreferences.Where(x => x.UserId.Equals(Id) && x.Url.Equals(pageUrl, StringComparison.InvariantCultureIgnoreCase) && x.Section.Equals(dataSection, StringComparison.InvariantCultureIgnoreCase)); if (prefRecords.Count() > 0) { UserPreference prefRec = prefRecords.First(); if (!String.IsNullOrEmpty(prefRec.Data)) result = prefRec.Data; } } return result; } } }