///------------------------------------------------------------------------------------------------- /// <summary> /// Removes the resource. /// </summary> /// /// <param name="key"> /// The key. /// </param> /// <param name="code"> /// (Optional) the code. /// </param> ///------------------------------------------------------------------------------------------------- public void RemoveResource(string key, LanguageCode code = LanguageCode.English) { key = key.ToLower(); using (SqlLocalizationContext configContext = new SqlLocalizationContext(this.nameOrConnectionString)) { LanguageResource resource = configContext.Resources.FirstOrDefault(x => x.Key == key && x.Code == code); if (resource != null) { configContext.Resources.Remove(resource); } configContext.SaveChanges(); } }
///------------------------------------------------------------------------------------------------- /// <summary> /// Saves a resource. /// </summary> /// /// <remarks> /// Anwar Javed, 03/19/2014 12:06 PM. /// </remarks> /// /// <param name="key"> /// The key. /// </param> /// <param name="text"> /// The text. /// </param> /// <param name="code"> /// (Optional) the code. /// </param> /// <param name="tooltipText"> /// (Optional) the tooltip text. /// </param> /// <param name="canShowTooltip"> /// (Optional) true if this ILanguageProvider can show tooltip. /// </param> /// <param name="category"> /// (Optional) The category. /// </param> ///------------------------------------------------------------------------------------------------- public void SaveResource( string key, string text, LanguageCode code = LanguageCode.English, string tooltipText = null, bool?canShowTooltip = null, string category = null) { key = key.ToLower(); using (SqlLocalizationContext configContext = new SqlLocalizationContext(this.nameOrConnectionString)) { LanguageResource resource = configContext.Resources.FirstOrDefault(x => x.Key == key && x.Code == code); if (resource == null) { resource = new LanguageResource(); resource.Code = code; resource.Key = key.ToLower(); resource.Text = string.Empty; resource.CanShowTooltip = true; configContext.Resources.Add(resource); } if (text != null) { resource.Text = text; } if (category != null) { resource.Category = category; } if (tooltipText != null) { resource.TooltipText = tooltipText; } if (canShowTooltip.HasValue) { resource.CanShowTooltip = canShowTooltip.Value; } configContext.SaveChanges(); } }