コード例 #1
0
        public static void DeletePluginLocaleResource(this BasePlugin plugin,
                                                      ILocalizationService localizationService, ILanguagesService languageService,
                                                      string resourceName)
        {
            //actually plugin instance is not required
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }
            if (localizationService == null)
            {
                throw new ArgumentNullException(nameof(localizationService));
            }
            if (languageService == null)
            {
                throw new ArgumentNullException(nameof(languageService));
            }

            foreach (var lang in languageService.GetAsEnumerable())
            {
                var lsr = localizationService.FindByName(resourceName, lang.Id);
                if (lsr != null)
                {
                    localizationService.Delete(lsr.Id);
                }
            }
        }
コード例 #2
0
        public void DeleteTest()
        {
            int count   = _memoryDbContext.Localizations.Count();
            var country = _memoryDbContext.Localizations.FirstOrDefault();

            Assert.IsTrue(_localizationService.Delete(country.ID));
            Assert.IsTrue(_memoryDbContext.Localizations.Count() == count - 1);
        }
コード例 #3
0
        public IActionResult ResourceDelete(int id)
        {
            var entity = _localizationService.GetById(id);

            _localizationService.Delete(entity);

            return(NoContent());
        }
コード例 #4
0
        public IActionResult Delete(int id)
        {
            var entity = _localizationService.GetById(id);

            _localizationService.Delete(entity);

            return(RedirectToAction("Get"));
        }
コード例 #5
0
        public IActionResult DeleteById(int id)
        {
            var foundDictionary = _localizationService.GetDictionaryItemById(id);

            if (foundDictionary == null)
            {
                return(NotFound());
            }

            var foundDictionaryDescendants = _localizationService.GetDictionaryItemDescendants(foundDictionary.Key);

            foreach (var dictionaryItem in foundDictionaryDescendants)
            {
                _localizationService.Delete(dictionaryItem, _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.Id);
            }

            _localizationService.Delete(foundDictionary, _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.Id);

            return(Ok());
        }
コード例 #6
0
    public IActionResult DeleteById(int id)
    {
        IDictionaryItem?foundDictionary = _localizationService.GetDictionaryItemById(id);

        if (foundDictionary == null)
        {
            return(NotFound());
        }

        IEnumerable <IDictionaryItem> foundDictionaryDescendants =
            _localizationService.GetDictionaryItemDescendants(foundDictionary.Key);

        foreach (IDictionaryItem dictionaryItem in foundDictionaryDescendants)
        {
            _localizationService.Delete(dictionaryItem, _backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.Id ?? -1);
        }

        _localizationService.Delete(foundDictionary, _backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.Id ?? -1);

        return(Ok());
    }
コード例 #7
0
        public void DeleteDefaultLanguage()
        {
            var testLanguage = new Language {
                Name = "test"
            };
            var settings = new Settings {
                DefaultLanguage = testLanguage
            };

            _settingsRepositorySub.GetSettings().Returns(settings);

            Assert.Throws <ApplicationException>(() => _localizationService.Delete(testLanguage));
        }
コード例 #8
0
        public void DeleteAllDictionaryItems()
        {
            var allItems = GetAllDictionaryItems();

            foreach (var item in allItems.OrderByDescending(x => !string.IsNullOrEmpty(x.ParentKey)))
            {
                var key = localizationService.GetDictionaryItemByKey(item.Key);
                if (key != null)
                {
                    localizationService.Delete(key);
                }
            }
        }
コード例 #9
0
 public virtual ActionResult Delete(int[] keys)
 {
     try
     {
         foreach (var key in keys)
         {
             _localizationService.Delete(key);
         }
         return(Content("OK"));
     }
     catch (Exception e)
     {
         var errorCode = ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Error(e, System.Web.HttpContext.Current));
         return(Content(string.Format(_localizationService.GetResource("ErrorOnOperation"), e.Message, errorCode)));
     }
 }
コード例 #10
0
        private async Task <SyncCommandResult> RemoveLanguage(string isoCode)
        {
            var existing = localizationService.GetLanguageByIsoCode(isoCode);

            if (existing != null && existing.IsoCode.Equals(isoCode, StringComparison.InvariantCultureIgnoreCase))
            {
                await writer.WriteLineAsync($"Removing Language ${isoCode}");

                localizationService.Delete(existing);
                return(SyncCommandResult.Success);
            }

            await writer.WriteLineAsync($"Language {isoCode} not installed");

            return(SyncCommandResult.NoResult);
        }
コード例 #11
0
        public virtual ActionResult ResourceDelete(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageLanguages))
            {
                return(AccessDeniedView());
            }
            var resource = _localizationService.GetEntityById(id);

            if (resource == null)
            {
                throw new ArgumentException("No resource found with the specified id");
            }
            _localizationService.Delete(resource);

            return(new JsonResult());
        }
        public override async Task <BaseResponse> Delete(QueryLanguageMessage request, ServerCallContext context)
        {
            var result = new BaseResponse();

            try
            {
                await _localizationService.Delete(request.DisplayKey);

                result.Code = ResponseCode.Success;
            }
            catch (Exception)
            {
                result.Code = ResponseCode.GeneralError;
            }

            return(result);
        }
コード例 #13
0
        public IActionResult DeleteConfirmed(Guid id)
        {
            if (id == null)
            {
                return(NotFound().WithError(LOCALIZATION_ERROR_NOT_FOUND));
            }

            try
            {
                _localizationService.Delete(id);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(RedirectToAction(nameof(Index)).WithError(ex.Message));
            }

            return(RedirectToAction(nameof(Index)).WithSuccess(LOCALIZATION_ERROR_CONCURENT_EDIT));
        }
コード例 #14
0
        public void DeleteById(string id)
        {
            Guid keyGuid;

            try
            {
                keyGuid = Guid.Parse(id);
            }
            catch (ArgumentNullException)
            {
                return;
            }
            var dictionaryItem = LocalizationService.GetDictionaryItemById(keyGuid);

            if (dictionaryItem != null)
            {
                LocalizationService.Delete(dictionaryItem, CurrentUserId);
            }
        }
コード例 #15
0
        public IActionResult DeleteLanguage(int id)
        {
            var language = _localizationService.GetLanguageById(id);

            if (language == null)
            {
                return(NotFound());
            }

            // the service would not let us do it, but test here nevertheless
            if (language.IsDefault)
            {
                var message = $"Language '{language.IsoCode}' is currently set to 'default' and can not be deleted.";
                return(ValidationProblem(message));
            }

            // service is happy deleting a language that's fallback for another language,
            // will just remove it - so no need to check here
            _localizationService.Delete(language);

            return(Ok());
        }
コード例 #16
0
 protected override void DeleteItem(IDictionaryItem item)
 => localizationService.Delete(item);
コード例 #17
0
ファイル: LanguageSerializer.cs プロジェクト: dinc5150/uSync8
 protected override void DeleteItem(ILanguage item)
 => localizationService.Delete(item);
 public void Delete(string culture, string key)
 {
     _localizationService
     .Delete(culture, key);
 }
コード例 #19
0
        private void CreateMilestoneItems()
        {
            try
            {
                if (createDictionaryItems)
                {
                    var language = new LanguageDictionaryService(localizationService, domainService, logger);
                    // Check if parent Key exists, and skip if true
                    if (!language.CheckExists(typeof(Forgot_ParentKey)))
                    {
                        // Add Dictionary Items
                        var dictionaryItems = new List <Type>
                        {
                            typeof(Forgot_ParentKey),
                            typeof(Forgot_EnterCaptcha),
                            typeof(Forgot_Captcha),
                            typeof(Forgot_ForgotUsernameSuccess),
                            typeof(Forgot_ForgotUsernameFailure),
                            typeof(Forgot_ChangePassword),
                            typeof(Forgot_ConfirmNewPassword),
                            typeof(Forgot_NewPassword),
                            typeof(Forgot_ChangePasswordSuccess),
                            typeof(Forgot_ForgotPasswordEmailSentToTitle),
                            typeof(Forgot_ForgotPasswordEmailSentTo),
                            typeof(Forgot_ResendResetPasswordEmail),
                            typeof(Forgot_ResendResetPasswordEmailSent),
                            typeof(Forgot_ForgotPasswordInstructions),
                            typeof(Forgot_ForgotUsernameInstructions),
                            typeof(Forgot_ForgotPassword),
                            typeof(Forgot_UsernameRequestSuccessful),

                            typeof(Others_ConfirmEmail),
                            typeof(Others_Successful)
                        };
                        language.CreateDictionaryItems(dictionaryItems); // Create Dictionary Items
                    }

                    if (!language.CheckExists(typeof(Reset_ParentKey)))
                    {
                        var resetPasswordViaEmailDictionary = new List <Type>
                        {
                            typeof(Reset_ParentKey),
                            typeof(Reset_ChangePassword),
                            typeof(Reset_ResetPasswordSuccess),
                            typeof(Reset_ResetPasswordFailure)
                        };
                        language.CreateDictionaryItems(resetPasswordViaEmailDictionary); // Create Dictionary Items
                    }
                    ConnectorContext.AuditService.Add(AuditType.Save, -1, -1, "Reset Password Dictionary Items", "Dictionaries Created");

                    if (!language.CheckExists(typeof(ServerErrors_ParentKey)))
                    {
                        var serverErrorsDictionary = new List <Type>
                        {
                            typeof(ServerErrors_ParentKey),
                            typeof(ServerErrors_MissingField),
                            typeof(ServerErrors_InvalidEmailFormat),
                            typeof(ServerErrors_InvalidDate),
                            typeof(ServerErrors_InvalidAge),
                            typeof(ServerErrors_MobileOrEmailRequired),
                            typeof(ServerErrors_InvalidCountry),
                            typeof(ServerErrors_InvalidCurrency),
                            typeof(ServerErrors_InvalidLanguage),
                            typeof(ServerErrors_InvalidTimeZone),
                            typeof(ServerErrors_ExistingCustomer),
                            typeof(ServerErrors_EmailNotFound),
                            typeof(ServerErrors_EmailSendFail),
                            typeof(ServerErrors_ChangePassword),
                            typeof(ServerErrors_InvalidCustomer),
                            typeof(ServerErrors_InvalidOldPassword),
                            typeof(ServerErrors_MatchingOldAndNewPassword),
                            typeof(ServerErrors_InvalidCustomerStatus),
                            typeof(ServerErrors_CustomerNotFound),
                            typeof(ServerErrors_VerificationRecordNotFound),
                            typeof(ServerErrors_VerificationEmailExpired),
                            typeof(ServerErrors_ValidationCodeExpired),
                            typeof(ServerErrors_ValidationCodeSendFail),
                            typeof(ServerErrors_SMSSendFail),
                            typeof(ServerErrors_InvalidMobileNumber),
                            typeof(ServerErrors_InvalidVerificationEmail),
                            typeof(ServerErrors_VerificationCodeLimitExceeded),
                            typeof(ServerErrors_MobileNumberNotFound),
                            typeof(ServerErrors_ValidationCodeInvalid),
                            typeof(ServerErrors_UnhandledError)
                        };
                        language.CreateDictionaryItems(serverErrorsDictionary); // Create Dictionary Items
                        ConnectorContext.AuditService.Add(AuditType.Save, -1, -1, "Server Error Dictionary Items", "Dictionaries Created");
                    }

                    var firstEmbeddedResource = new Milestone7EmbeddedResources().Resources[0];
                    if (!ContentHelper.AssetAlreadyExists(firstEmbeddedResource.FileName, firstEmbeddedResource.OutputDirectory))
                    {
                        ContentHelper.CopyPhysicalAssets(new Milestone7EmbeddedResources());
                        ConnectorContext.AuditService.Add(AuditType.Save, -1, -1, "Templates", "Templates Created");
                    }

                    // changed Email Confirmation page to remove from Allowed in Root
                    var confirmEmailDocType = contentTypeService.Get(_03_ConfirmEmailDocumentType.DOCUMENT_TYPE_ALIAS);
                    if (!confirmEmailDocType.AllowedAsRoot)
                    {
                        confirmEmailDocType.AllowedAsRoot = false;
                        contentTypeService.Save(confirmEmailDocType);
                    }

                    // delete en-GB
                    var enGB = localizationService.GetLanguageByIsoCode("en-GB");
                    if (enGB != null)
                    {
                        localizationService.Delete(enGB);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(typeof(_06_Phase2Milestone7), ex.Message);
                logger.Error(typeof(_06_Phase2Milestone7), ex.StackTrace);
            }
        }