/// <summary>
        /// Fetches crud access per roletemplate for a Page
        /// </summary>
        /// <param name="page">Page for which we are finding Role template access</param>
        /// <returns>List of roles and its crud access level</returns>
        public static List <AccessPageModel> GetPageAccess(SystemEnum.Page page)
        {
            List <AccessPageModel> result = new List <AccessPageModel>();

            try
            {
                using (var ctx = new LicenseApplicationContext())
                {
                    var roles       = ctx.RoleTemplates.ToList();
                    int screenId    = page.GetHashCode();
                    var accessPages = ctx.AccessPages.Where(o => o.ScreenId == screenId).ToList();
                    foreach (var role in roles)
                    {
                        if (accessPages.Any(ap => ap.RoleTemplateID == role.RoleTemplateID))
                        {
                            var accessPage = accessPages.First(ap => ap.RoleTemplateID == role.RoleTemplateID);
                            result.Add(AutoMapper.Mapper.Map <AccessPageModel>(accessPage));
                        }
                        else
                        {
                            result.Add(new AccessPageModel()
                            {
                                RoleTemplateID   = role.RoleTemplateID,
                                PageDesc         = page.ToString(),
                                ScreenId         = page.GetHashCode(),
                                RoleTemplateDesc = role.RoleTemplateDesc
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(result);
        }
        /// <summary>
        /// Determines whether the specified page type has access.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <returns>has access or not</returns>
        public static bool HasAccess(SystemEnum.Page page, SystemEnum.PageRight pageRight)
        {
            bool result = false;

            try
            {
                using (var ctx = new LicenseApplicationContext())
                {
                    if (ProjectSession.User != null)
                    {
                        int screenId  = page.GetHashCode();
                        int crudLevel = pageRight.GetHashCode();
                        result = ctx.AccessPages.Where(o => o.RoleTemplateID == ProjectSession.User.RoleTemplateID && o.ScreenId == screenId && o.CrudLevel >= crudLevel).Count() > 0 ? true : false;
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(result);
        }