public static IList<EFTemplate> GetTemplatesForUserGroup(EFUserGroup userGroup) { var result = new List<EFTemplate>(); var findRootSqlQry = string.Format("SELECT TemplateId from dbo.Template where UserGroupId = {0} and Parent_TemplateId is NULL",userGroup.UserGroupId); var roots = Context.Database.SqlQuery<int>(findRootSqlQry).ToList<int>(); GetTemplateForRoots(roots, result); return result; }
public static void FillCacheWithAllMailForUser(EFUserGroup userGroup) { try { _cacheMails = Context.Mails .Where(x => x.UserGroupId == userGroup.UserGroupId) .Select<EFMail, IMail>(u => u) .ToDictionary(x => x.MailScanId); _cacheMailGroups = Context.MailGroups .Include(x => x.DataUnits) .Include(x => x.Emails) .Where(x => x.Emails.Any()) .Where(x => x.Emails.FirstOrDefault().UserGroup.UserGroupId == userGroup.UserGroupId) .Select<EFMailGroup, IMailGroup>(u => u) .ToDictionary(x => x.MailGroupScanId); } catch (Exception e) { _cacheMailGroups = new Dictionary<string, IMailGroup>(); _cacheMails = new Dictionary<string, IMail>(); _logger.ErrorFormat("Error while creating Mail manager cache => {0}", e); } }
public static EFTemplate GetDefaultTemplatesForUserGroup(EFUserGroup userGroup) { return GetTemplatesForUserGroup(userGroup).FirstOrDefault(); }