public async Task DeleteAsync_should_not_throw_when_parent_not_exists() { using var store = new RavenDbTestDriverWrapper().GetDocumentStore(); var entity = new LocalizedResource { Id = Guid.NewGuid().ToString(), CultureId = "test" }; using var s1 = store.OpenAsyncSession(); await s1.StoreAsync(entity, $"{typeof(LocalizedResource).Name.ToLowerInvariant()}/{entity.Id}"); await s1.SaveChangesAsync(); var loggerMock = new Mock <ILogger <AdminStore <LocalizedResource> > >(); using var session = store.OpenAsyncSession(); var sut = CreateSut(session, loggerMock.Object); await sut.DeleteAsync(entity.Id); using var s2 = store.OpenAsyncSession(); Assert.Null(await s2.LoadAsync <LocalizedResource>($"{typeof(LocalizedResource).Name.ToLowerInvariant()}/{entity.Id}")); }
public async Task CreateAsync_should_add_entity_id_to_parent() { using var store = new RavenDbTestDriverWrapper().GetDocumentStore(); using var s1 = store.OpenAsyncSession(); await s1.StoreAsync(new Culture { Id = "test" }, $"{nameof(Culture).ToLowerInvariant()}/test"); await s1.SaveChangesAsync(); var loggerMock = new Mock <ILogger <AdminStore <LocalizedResource> > >(); using var session = store.OpenAsyncSession(); var sut = CreateSut(session, loggerMock.Object); var entity = new LocalizedResource { Id = Guid.NewGuid().ToString(), CultureId = "test" }; await sut.CreateAsync(entity); using var s2 = store.OpenAsyncSession(); var parent = await s2.LoadAsync <Culture>($"{nameof(Culture).ToLowerInvariant()}/test"); var collection = GetCollection(parent); Assert.Contains(collection, i => i.Id == $"{typeof(LocalizedResource).Name.ToLowerInvariant()}/{entity.Id}"); }
private void PrepareResourceModel(LocalizedResourceModel model, LocalizedResource entity) { if (null != entity) { model = entity.MapTo(model); } }
public void Init() { _localizedResource = new LocalizedResource(Resource.ResourceManager.BaseName); var culture = "zh-CN"; LocalizationHelper.SetCulture(culture); Resource.Culture = new CultureInfo(culture); }
public LocalizedResourceManageModel(LocalizedResource localizedResource) : this(localizedResource.LanguageId) { Id = localizedResource.Id; TextKey = localizedResource.TextKey; DefaultValue = localizedResource.DefaultValue; TranslatedValue = localizedResource.TranslatedValue; }
public LocalizerResourceRequestEvent(LocalizedResource resource, LocalResourceVisibility vis, LocalizerContext context, string pattern) : base(LocalizerEventType.RequestResourceLocalization, ConverterUtils.ToString(context .GetContainerId())) { this.vis = vis; this.context = context; this.resource = resource; this.pattern = pattern; }
public LocalizedResourceModel(LocalizedResource localizedResource) : this() { LanguageId = localizedResource.LanguageId; Language = localizedResource.Language.Key; TextKey = localizedResource.TextKey; DefaultValue = localizedResource.DefaultValue; TranslatedValue = localizedResource.TranslatedValue; Created = localizedResource.Created; CreatedBy = localizedResource.CreatedBy; LastUpdate = localizedResource.LastUpdate; LastUpdateBy = localizedResource.LastUpdateBy; }
public async Task CreateAsync_should_throw_when_parent_not_exists() { using var store = new RavenDbTestDriverWrapper().GetDocumentStore(); var loggerMock = new Mock <ILogger <AdminStore <LocalizedResource> > >(); using var session = store.OpenAsyncSession(); var sut = CreateSut(session, loggerMock.Object); var entity = new LocalizedResource { Id = Guid.NewGuid().ToString(), CultureId = "test" }; await Assert.ThrowsAsync <InvalidOperationException>(() => sut.CreateAsync(entity)); }
/// <summary> /// Update new value to database /// </summary> /// <param name="textKey"></param> /// <param name="defaultValue"></param> /// <param name="parameters"> </param> private string UpdateDictionaryToDb(string textKey, string defaultValue, params object[] parameters) { var existedResourceIds = Fetch(l => l.TextKey.Equals(textKey)).Select(l => l.LanguageId).ToList(); var languages = _languageRepository.Fetch(l => !existedResourceIds.Contains(l.Id)).ToList(); foreach (var language in languages) { var localizeResource = new LocalizedResource { TextKey = textKey, DefaultValue = defaultValue, TranslatedValue = string.Empty, LanguageId = language.Id }; Insert(localizeResource); } RefreshDictionary(); if (parameters != null && parameters.Any()) { return(string.Format(defaultValue, parameters)); } return(defaultValue); }
internal ResponseModel Insert(LocalizedResource localizedResource) { return(_localizedResourceRepository.Insert(localizedResource)); }
public void DeleteResource(LocalizedResource resource) { localizedResourceRepository.Delete(resource); cacheManager.RemoveByPattern(RESOURCE_CACHE_PATTERN); }
public async Task UpdateAsync(LocalizedResource resource) => await _database.LocalizedResources().ReplaceOneAsync(x => x.Id == resource.Id, resource);
public ResponseModel Update(LocalizedResource localizedResource) { return(_localizedResourceRepository.Update(localizedResource)); }
public void Init() { _localizedResource = new XfLocalizedResource(); }
public async Task DeleteAsync(LocalizedResource resource) => await _database.LocalizedResources().DeleteOneAsync(x => x.Id == resource.Id);
internal ResponseModel Delete(LocalizedResource localizedResource) { return(_localizedResourceRepository.Delete(localizedResource)); }
/** * */ public LocaleMessages() { bundle = new LocalizedResource("iTextSharp.errors.errors", CultureInfo.CurrentCulture, Assembly.GetExecutingAssembly()); }
public async Task AddAsync(LocalizedResource resource) => await _database.LocalizedResources().InsertOneAsync(resource);