示例#1
0
        protected async Task EditLocalizationRecordKey()
        {
            if (oldKey != null && newKey != null && oldKey != newKey)
            {
                try
                {
                    localizationApiClient.ClearEntitiesCache();
                    var response = await localizationApiClient.EditLocalizationRecordKey(oldKey, newKey);

                    if (response.IsSuccessStatusCode)
                    {
                        await LoadKeys();

                        localizationRecords = new List <LocalizationRecord>();
                        LocalizationCultures.Clear();

                        viewNotifier.Show(L["Operation Successful"], ViewNotifierType.Success);
                    }
                    else
                    {
                        viewNotifier.Show(response.Message, ViewNotifierType.Warning, L["Operation Failed"]);
                    }
                }
                catch (Exception ex)
                {
                    viewNotifier.Show(ex.GetBaseException().Message, ViewNotifierType.Error, L["Operation Failed"]);
                }
            }

            isEditDialogOpen = false;

            StateHasChanged();
        }
示例#2
0
        protected async Task DeleteLocalizationRecordKey(LocalizationRecordKey key)
        {
            if (key != null)
            {
                try
                {
                    localizationApiClient.ClearEntitiesCache();
                    var response = await localizationApiClient.DeleteLocalizationRecordKey(key);


                    if (response.IsSuccessStatusCode)
                    {
                        await LoadKeys();

                        localizationRecords = new List <LocalizationRecord>();
                        LocalizationCultures.Clear();

                        matToaster.Add(response.Message, MatToastType.Success, L["Operation Successful"]);
                    }
                    else
                    {
                        matToaster.Add(response.Message, MatToastType.Warning, L["Operation Failed"]);
                    }
                }
                catch (Exception ex)
                {
                    matToaster.Add(ex.GetBaseException().Message, MatToastType.Danger, L["Operation Failed"]);
                }
            }

            isDeleteDialogOpen = false;

            StateHasChanged();
        }
示例#3
0
        protected async Task DeleteLocalizationRecordKey(LocalizationRecordKey key)
        {
            if (key != null)
            {
                try
                {
                    localizationApiClient.ClearEntitiesCache();
                    var response = await localizationApiClient.DeleteLocalizationRecordKey(key);

                    if (response.IsSuccessStatusCode)
                    {
                        await Reload();

                        LocalizationCultures.Clear();

                        viewNotifier.Show(response.Message, ViewNotifierType.Success, L["Operation Successful"]);
                    }
                    else
                    {
                        viewNotifier.Show(response.Message, ViewNotifierType.Warning, L["Operation Failed"]);
                    }
                }
                catch (Exception ex)
                {
                    viewNotifier.Show(ex.GetBaseException().Message, ViewNotifierType.Error, L["Operation Failed"]);
                }
            }

            isDeleteDialogOpen = false;

            StateHasChanged();
        }
示例#4
0
        protected async Task LoadLocalizationRecords(LocalizationRecordKey key)
        {
            if (key != null)
            {
                try
                {
                    if (currentKey != null)
                    {
                        currentKey.LocalizationRecords = null;
                    }

                    currentKey = key;
                    localizationApiClient.ClearEntitiesCache();
                    var result = await localizationApiClient.GetLocalizationRecords(key);

                    currentKey.LocalizationRecords = new List <LocalizationRecord>(result);

                    LocalizationCultures.Clear();

                    LocalizationCultures.AddRange(SupportedCultures
                                                  .Where(i => !currentKey.LocalizationRecords.Any(l => l.Culture == i)));

                    if (LocalizationCultures.Count > 0)
                    {
                        newLocalizationRecord = new LocalizationRecord()
                        {
                            ContextId = currentKey.ContextId, MsgId = currentKey.MsgId, Culture = LocalizationCultures[0]
                        }
                    }
                    ;

                    viewNotifier.Show(L["One item found", Plural.From("{0} items found", result.Count())], ViewNotifierType.Success, L["Operation Successful"]);
                }
                catch (Exception ex)
                {
                    viewNotifier.Show(ex.GetBaseException().Message, ViewNotifierType.Error, L["Operation Failed"]);
                }
            }

            StateHasChanged();
        }
示例#5
0
        protected async Task LoadLocalizationRecords(LocalizationRecordKey key)
        {
            if (key != null)
            {
                try
                {
                    currentKey = key;
                    localizationApiClient.ClearEntitiesCache();
                    var result = await localizationApiClient.GetLocalizationRecords(key);

                    localizationRecords = new List <LocalizationRecord>(result);

                    LocalizationCultures.Clear();

                    LocalizationCultures.AddRange(BlazorBoilerplate.Shared.Localizer.Settings.SupportedCultures
                                                  .Where(i => !localizationRecords.Any(l => l.Culture == i)));

                    if (LocalizationCultures.Count > 0)
                    {
                        newLocalizationRecord = new LocalizationRecord()
                        {
                            ContextId = currentKey.ContextId, MsgId = currentKey.MsgId, Culture = LocalizationCultures[0]
                        }
                    }
                    ;

                    matToaster.Add(L["One item found", Plural.From("{0} items found", result.Count())], MatToastType.Success, L["Operation Successful"]);
                }
                catch (Exception ex)
                {
                    matToaster.Add(ex.GetBaseException().Message, MatToastType.Danger, L["Operation Failed"]);
                }
            }
            else
            {
                localizationRecords = new List <LocalizationRecord>();
            }

            StateHasChanged();
        }
示例#6
0
        protected async Task LoadLocalizationRecords(string key)
        {
            if (key != null)
            {
                try
                {
                    currentKey = key;
                    localizationApiClient.ClearEntitiesCache();
                    var result = await localizationApiClient.GetLocalizationRecords(key);

                    localizationRecords = new List <ILocalizationRecord>(result);

                    LocalizationCultures.Clear();

                    LocalizationCultures.AddRange(BlazorBoilerplate.Shared.SqlLocalizer.Settings.SupportedCultures
                                                  .Where(i => !localizationRecords.Any(l => l.LocalizationCulture == i)));

                    if (LocalizationCultures.Count > 0)
                    {
                        newLocalizationRecord = new LocalizationRecord()
                        {
                            Key = currentKey, LocalizationCulture = LocalizationCultures[0]
                        }
                    }
                    ;

                    matToaster.Add($"Total Items: {localizationRecords.Count}", MatToastType.Success, L["Operation Successful"]);
                }
                catch (Exception ex)
                {
                    matToaster.Add(ex.GetBaseException().Message, MatToastType.Danger, L["Operation Failed"]);
                }
            }
            else
            {
                localizationRecords = new List <ILocalizationRecord>();
            }

            StateHasChanged();
        }
示例#7
0
        protected async Task LoadPluralFormRules()
        {
            PluralFormRules = new List <PluralFormRule>();

            try
            {
                localizationApiClient.ClearEntitiesCache();
                var result = await localizationApiClient.GetPluralFormRules();

                PluralFormRules = new List <PluralFormRule>(result);

                LocalizationCultures.Clear();

                LocalizationCultures.AddRange(BlazorBoilerplate.Shared.Localizer.Settings.SupportedCultures
                                              .Where(i => !PluralFormRules.Any(l => l.Language == i)));

                matToaster.Add(L["One item found", Plural.From("{0} items found", PluralFormRules.Count)], MatToastType.Success, L["Operation Successful"]);
            }
            catch (Exception ex)
            {
                matToaster.Add(ex.GetBaseException().Message, MatToastType.Danger, L["Operation Failed"]);
            }
        }
示例#8
0
        protected async Task LoadPluralFormRules()
        {
            PluralFormRules = new List <PluralFormRule>();

            try
            {
                localizationApiClient.ClearEntitiesCache();
                var result = await localizationApiClient.GetPluralFormRules();

                PluralFormRules = new List <PluralFormRule>(result);

                LocalizationCultures.Clear();

                LocalizationCultures.AddRange(SupportedCultures
                                              .Where(i => !PluralFormRules.Any(l => l.Language == i)));

                viewNotifier.Show(L["One item found", Plural.From("{0} items found", PluralFormRules.Count)], ViewNotifierType.Success, L["Operation Successful"]);
            }
            catch (Exception ex)
            {
                viewNotifier.Show(ex.GetBaseException().Message, ViewNotifierType.Error, L["Operation Failed"]);
            }
        }