Example #1
0
        public async Task <Result <LocalizedValuesErrorCodes> > UpdateAsync(LocalizedValue value, string userName,
                                                                            string correlationId)
        {
            if (!await _localesRepository.ExistsAsync(value.Locale))
            {
                return(new Result <LocalizedValuesErrorCodes>(LocalizedValuesErrorCodes.LocaleDoesNotExist));
            }

            var existing = await _localizedValuesRepository.GetAsync(value.Locale, value.Key);

            if (existing.IsSuccess)
            {
                var result = await _localizedValuesRepository.UpdateAsync(value);

                if (result.IsSuccess)
                {
                    await _auditService.TryAudit(correlationId, userName, GetId(value), AuditDataType.LocalizedValue,
                                                 value.ToJson(), existing.Value.ToJson());
                }

                return(result);
            }

            return(existing.ToResultWithoutValue());
        }