public static IList<DocTemplate> GetTemplatesOnlyForOrganization(IUnitOfWork uow, TemplateType type, Organization org)
 {
     return uow.Session.QueryOver<DocTemplate> ()
         .Where(x => x.TemplateType == type)
         .Where(x => x.Organization == org)
         .List<DocTemplate> ();
 }
        /// <summary>
        /// Получаем первый подходящий шаболон документа по указанным критериям.
        /// </summary>
        public static DocTemplate GetTemplate(IUnitOfWork uow, TemplateType type, Organization org)
        {
            var forOrg = GetTemplatesOnlyForOrganization(uow, type, org);
            if (forOrg.Count > 0)
                return forOrg.First();

            var any = GetTemplatesForAnyOrganization(uow, type);
            return any.FirstOrDefault();
        }