Esempio n. 1
0
        public virtual TblLocalizedStrings FindByName(string resourceName, int languageId, bool logIfNotFound = false)
        {
            var result = GetAsEnumerable().FirstOrDefault(p =>
                                                          p.ResourceName.Trim().Equals(resourceName.Trim(), StringComparison.InvariantCultureIgnoreCase) &&
                                                          p.LanguageId == languageId);

            if (result == null && logIfNotFound)
            {
                try
                {
                    var language = _languagesService.FindById(languageId);
                    Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(
                        new Error(
                            new Exception(
                                $"Can not found resource with name '{resourceName}' (Language: {language?.LanguageName ?? " ID= " + languageId})"),
                            System.Web.HttpContext.Current)
                    {
                        Type = "Localization Warning"
                    });
                }
                catch
                {}
            }

            return(result);
        }