public async Task <int> CreateAsync(CreateAssetTypeDto request) { AssetType assetType = AssetTypeMapper.Map(request) ?? throw new ArgumentNullException(nameof(request)); if (await _assetTypeRepository.AnyAsync(x => x.Name.Equals(request.Name))) { throw new ValidationException($"{request.Name} already exist."); } _assetTypeRepository.Add(assetType); return(await _unitOfWork.SaveChangesAsync()); }
public void Add(AssetType assetType) { _assetTypeRepository.Add(assetType); }