sozsoft-platform/api/modules/Sozsoft.Languages/Sozsoft.Languages.Application/LanguageKeyAppService.cs
Sedat Öztürk 429227df1d Initial
2026-02-24 23:44:16 +03:00

49 lines
1.5 KiB
C#

using Sozsoft.Languages.Entities;
using Sozsoft.Languages.Localization;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Validation;
namespace Sozsoft.Languages;
public class LanguageKeyAppService : CrudAppService<
LanguageKey,
LanguageKeyDto,
Guid,
PagedAndSortedResultRequestDto>,
ILanguageKeyAppService
{
private readonly IRepository<LanguageKey, Guid> _repository;
public LanguageKeyAppService(
IRepository<LanguageKey, Guid> repository
) : base(repository)
{
LocalizationResource = typeof(LanguagesResource);
ObjectMapperContext = typeof(LanguagesApplicationModule);
_repository = repository;
}
public override async Task<LanguageKeyDto> CreateAsync(LanguageKeyDto input)
{
var recordExists = await _repository.AnyAsync(
a => a.ResourceName == input.ResourceName
&& a.Key == input.Key);
if (recordExists)
{
var validationErrors = new ValidationResult(
L["Error:UniqueControl"],
new string[] { "ResourceName", "Key" }
);
throw new AbpValidationException(new List<ValidationResult> { validationErrors });
}
return await base.CreateAsync(input);
}
}