<commit_before>﻿using SFA.DAS.CosmosDb;
using SFA.DAS.EAS.Portal.Database;
using SFA.DAS.EAS.Portal.Client.Database.Models;
using System.Threading;
using System.Threading.Tasks;

namespace SFA.DAS.EAS.Portal.Application.Services
{
    public class AccountDocumentService : IAccountDocumentService
    {
        private readonly IAccountsRepository _accountsRepository;
        
        public AccountDocumentService(IAccountsRepository accountsRepository)
        {
            _accountsRepository = accountsRepository;
        }
        public Task<AccountDocument> Get(long id, CancellationToken cancellationToken = default)
        {
            return _accountsRepository.CreateQuery()
               .SingleOrDefaultAsync(a => a.AccountId == id, cancellationToken);            
        }

        public async Task<AccountDocument> GetOrCreate(long id, CancellationToken cancellationToken = default)
        {
            return await Get(id, cancellationToken) ?? new AccountDocument(id);
        }

        
        public Task Save(AccountDocument account, CancellationToken cancellationToken = default)
        {
            if (account.IsNew)
            {               
                return _accountsRepository.Add(account, null, cancellationToken);
            }

            return _accountsRepository.Update(account, null, cancellationToken);
        }
    }
}<commit_msg>remove whitespace<commit_after>﻿using SFA.DAS.CosmosDb;
using SFA.DAS.EAS.Portal.Database;
using SFA.DAS.EAS.Portal.Client.Database.Models;
using System.Threading;
using System.Threading.Tasks;

namespace SFA.DAS.EAS.Portal.Application.Services
{
    public class AccountDocumentService : IAccountDocumentService
    {
        private readonly IAccountsRepository _accountsRepository;
        
        public AccountDocumentService(IAccountsRepository accountsRepository)
        {
            _accountsRepository = accountsRepository;
        }
        public Task<AccountDocument> Get(long id, CancellationToken cancellationToken = default)
        {
            return _accountsRepository.CreateQuery()
               .SingleOrDefaultAsync(a => a.AccountId == id, cancellationToken);            
        }

        public async Task<AccountDocument> GetOrCreate(long id, CancellationToken cancellationToken = default)
        {
            return await Get(id, cancellationToken) ?? new AccountDocument(id);
        }

        public Task Save(AccountDocument account, CancellationToken cancellationToken = default)
        {
            if (account.IsNew)
            {               
                return _accountsRepository.Add(account, null, cancellationToken);
            }

            return _accountsRepository.Update(account, null, cancellationToken);
        }
    }
}
{'fraction_non_alphanumeric': 0.07284529390551749, 'fraction_numerical': 0.0, 'mean_word_length': 2.5337579617834396, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '679793', 'n_tokens_mistral': 683, 'n_tokens_neox': 687, 'n_words': 139}