public void ConvertNullAPIToAPI()
        {
            apiAccount = null;
            converter  = new AccountConverter(apiAccount);

            Assert.IsNull(converter.ToAPIAccount());
        }
示例#2
0
 public IEnumerable <Account> GetNewAccounts()
 {
     return((from a in Context.Accounts
             where a.Created > Context.NewDate
             orderby a.Name ascending
             select AccountConverter.ToDomain(a)).AsEnumerable());
 }
示例#3
0
        public Account GetAccount(Guid WorkDoneItemId)
        {
            var inv = GetOpportunity(WorkDoneItemId);
            var acc = Context.Accounts.Single(a => a.Id == inv.AccountId);

            return(AccountConverter.ToDomain(acc));
        }
        public void ConvertSDKToAPI()
        {
            sdkAccount = CreateTypicalSDKAccount();
            converter  = new AccountConverter(sdkAccount);

            OneSpanSign.API.Account account = converter.ToAPIAccount();

            Assert.IsNotNull(account);
            Assert.AreEqual(ACC_NAME, account.Name);

            Assert.AreEqual(ACC_CO_ID, account.Company.Id);
            Assert.AreEqual(ACC_CO_ADDR_ADDR1, account.Company.Address.Address1);

            Assert.AreEqual(1, account.CustomFields.Count);
            Assert.AreEqual(ACC_FIELD_DEF_VLE, account.CustomFields[0].Value);
            Assert.AreEqual(1, account.CustomFields[0].Translations.Count);
            Assert.AreEqual(ACC_FIELD_TRANSL_LANG, account.CustomFields[0].Translations[0].Language);

            Assert.AreEqual(1, account.Licenses.Count);
            Assert.AreEqual(ACC_LIC_STATUS, account.Licenses[0].Status);
            Assert.AreEqual(1, account.Licenses[0].Transactions.Count);
            Assert.AreEqual(ACC_LIC_TRANS_CC_NUM, account.Licenses[0].Transactions[0].CreditCard.Number);
            Assert.AreEqual(ACC_LIC_TRANS_PRICE_AMOUNT, account.Licenses[0].Transactions[0].Price.Amount);
            Assert.AreEqual(ACC_LIC_PLAN_CONTRACT, account.Licenses[0].Plan.Contract);
            Assert.AreEqual(ACC_LIC_PLAN_PRICE_AMOUNT, account.Licenses[0].Plan.Price.Amount);

            Assert.AreEqual(1, account.Providers.Documents.Count);
            Assert.AreEqual(ACC_PROV_DOC_NAME, account.Providers.Documents[0].Name);
            Assert.AreEqual(1, account.Providers.Users.Count);
            Assert.AreEqual(ACC_PROV_USR_NAME, account.Providers.Users[0].Name);
        }
示例#5
0
        public ResultGeneric <List <GetAccountsResponse> > GetAccountsByDocument(string cpf)
        {
            var result = new ResultGeneric <List <GetAccountsResponse> >();
            var client = clientRepository.getByDocument(cpf);

            if (client != null)
            {
                var accounts = accountRepository.GetAllAccountsByClientID(client.ClientID);

                if (accounts.Count > 0)
                {
                    var retorno = new List <GetAccountsResponse>();
                    accounts.ForEach(a => retorno.Add(AccountConverter.Parse(a, cpf)));

                    result.Data    = retorno;
                    result.Success = true;
                }
                else
                {
                    result.Success = false;;
                    result.Errors.Add("Nenhuma conta localizada");
                }
            }
            else
            {
                result.Success = false;;
                result.Errors.Add("Cliente não localizado com o CPF: " + cpf);
            }

            return(result);
        }
        public void ConvertNullSDKToAPI()
        {
            sdkAccount = null;
            converter  = new AccountConverter(sdkAccount);

            Assert.IsNull(converter.ToAPIAccount());
        }
        public void ConvertSDKToSDK()
        {
            sdkAccount = CreateTypicalSDKAccount();
            converter  = new AccountConverter(sdkAccount);
            Account account = converter.ToSDKAccount();

            Assert.IsNotNull(account);
            Assert.AreEqual(sdkAccount, account);
        }
示例#8
0
 public IEnumerable <Account> GetActiveAccounts()
 {
     return((from a in Context.Accounts
             join i in Context.Invoices
             on a.Id equals i.AccountId
             where i.InvoiceDate > Context.ActiveDate
             orderby a.Name ascending
             select AccountConverter.ToDomain(a)).Distinct().AsEnumerable());
 }
示例#9
0
        public AccountDTO AddAccountToUser(AccountDTO accountDTO, string username)
        {
            var user = userService.GetEntityByUsername(username);

            user.Account = AccountConverter.ToEntity(accountDTO);
            userService.Save(user);

            return(accountDTO);
        }
示例#10
0
        public IEnumerable <AccountDTO> deleteAccountFromClient(String clientId, int accountId)
        {
            Client client = clientRepository.GetByID(clientId);

            accountRepository.Delete(accountId);


            return(AccountConverter.toDtos(accountRepository.Get().Where(x => x.Client.SocialSecurityNumber == clientId)));
        }
 public AccountRemoteDataSource(
     ILogger <AccountRemoteDataSource> logger,
     AccountClient client,
     AccountConverter converter
     )
 {
     this.logger    = logger;
     this.client    = client;
     this.converter = converter;
 }
示例#12
0
        public void Passing()
        {
            AccountConverter converter = new AccountConverter();

            var address = "xrb_39ymww61tksoddjh1e43mprw5r8uu1318it9z3agm7e6f96kg4ndqg9tuds4";
            var decode  = converter.DecodeAccount(address);
            var encode  = converter.EncodeAccount(decode);

            Assert.Equal(address, encode);
        }
示例#13
0
        public AccountDTO getAccountById(int accountId)
        {
            Account account = accountRepository.GetByID(accountId);

            if (account == null)
            {
                throw new InvalidOperationException("No account found with that accountId");
            }
            return(AccountConverter.toDto(account));
        }
        public void ConvertAPIToAPI()
        {
            apiAccount = CreateTypicalAPIAccount();
            converter  = new AccountConverter(apiAccount);

            OneSpanSign.API.Account account = converter.ToAPIAccount();

            Assert.IsNotNull(account);
            Assert.AreEqual(apiAccount, account);
        }
示例#15
0
        public AccountDTO GetAccount(string username)
        {
            var acc = GetAccountForUser(username);

            if (acc == null)
            {
                return(null);
            }
            return(AccountConverter.ToDTO(acc));
        }
示例#16
0
        public Account GetItem(Guid id)
        {
            var account = (from a in Context.Accounts
                           where a.Id == id
                           select AccountConverter.ToDomain(a)).Single();

            account.Invoices      = GetInvoices(id, Context.ActiveDate);
            account.Opportunities = GetNewAndActiveOpportunities(id, Context.NewDate, Context.ActiveDate);

            return(account);
        }
示例#17
0
 public IEnumerable <ReportProfitItem> GetProfitData()
 {
     return(from a in accounts
            join p in allocations on a.Id equals p.AccountId
            select new ReportProfitItem
     {
         Account = AccountConverter.ConvertToDomain(a),
         Allocation = AllocationConverter.ConvertToDomain(p),
         WorkDoneMargin = GetWorkDoneMargin(a.Id, GetMonthStart(p.Month))
     });
 }
示例#18
0
 public IEnumerable <ReportWorkDoneItem> GetWorkDoneItems()
 {
     return(from a in accounts
            join i in invoices on a.Id equals i.AccountId
            join w in workDoneItems on i.Id equals w.InvoiceId
            where (bool)w.Active && (bool)i.Active
            select new ReportWorkDoneItem
     {
         Account = AccountConverter.ConvertToDomain(a),
         Invoice = InvoiceConverter.ConvertToDomain(i),
         WorkDoneItem = WorkDoneItemConverter.ConvertToDomain(w)
     });
 }
示例#19
0
        public AccountDTO updateAccount(int accountId, AccountDTO accountDto)
        {
            Account account = accountRepository.GetByID(accountId);

            if (account == null)
            {
                throw new InvalidOperationException("No account found with that id");
            }

            account.Amount = accountDto.Amount;

            accountRepository.Update(account);
            return(AccountConverter.toDto(account));
        }
示例#20
0
        public AccountDTO UpdateAccount(AccountDTO accountDTO, string username)
        {
            var user       = userService.GetEntityByUsername(username);
            var updatedAcc = AccountConverter.ToEntity(accountDTO);

            if (user.AccountId == null)
            {
                return(null);
            }
            updatedAcc.Id = user.AccountId.Value;
            user.Account  = updatedAcc;
            repository.Save(updatedAcc);
            return(accountDTO);
        }
示例#21
0
        public void AddAndGetAccount2()
        {
            IRepository <FrontiersDb> _repo = new LiteDBRepository <FrontiersDb>(_databaseSetting);
            var address = "xrb_39ymww61tksoddjh1e43mprw5r8uu1318it9z3agm7e6f96kg4ndqg9tuds4";
            AccountConverter converter = new AccountConverter();
            var         accountUInt256 = converter.DecodeAccount(address);
            FrontiersDb frontierEntry  = new FrontiersDb();

            frontierEntry.Account = accountUInt256;
            _repo.Insert(frontierEntry);
            var accountFind = converter.DecodeAccount(address);
            var found       = _repo.FindOneById(accountFind);

            Assert.NotNull(found);
        }
示例#22
0
        public IEnumerable <AccountDTO> addAccountToClient(String clientId, int accountId)
        {
            Client  client  = clientRepository.GetByID(clientId);
            Account account = accountRepository.GetByID(accountId);

            if (client == null || account == null)
            {
                throw new InvalidOperationException("Client or account does not exist");
            }

            account.Client = client;
            accountRepository.Update(account);

            return(AccountConverter.toDtos(accountRepository.Get().Where(x => x.Client.SocialSecurityNumber == clientId)));
        }
示例#23
0
        public AccountDTO createAccount(AccountDTO accountDto)
        {
            if (accountDto.Amount < 0)
            {
                throw new InvalidOperationException("Impossible to have a negative balance");
            }
            Account account = new Account
            {
                Client       = null,
                CreationDate = DateTime.Now,
                Amount       = accountDto.Amount,
                Id           = accountDto.Id,
                Type         = accountDto.Type
            };

            accountRepository.Insert(account);

            return(AccountConverter.toDto(account));
        }
示例#24
0
        public ResultGeneric <PostClientAccountResponse> Register(PostClientAccountRequest entity)
        {
            var accountCreate = new ResultGeneric <PostClientAccountResponse>();

            var newClient  = ClientConverter.Parse(entity);
            var newAccount = AccountConverter.Parse(entity);
            var clientID   = new Guid();

            #region Client
            var client = clientRepository.getByDocument(entity.CPF);
            if (client != null)
            {
                clientID = client.ClientID;
            }
            else
            {
                clientRepository.Insert(newClient);
                clientID = newClient.ClientID;
            }
            #endregion

            #region Account

            if (!accountRepository.AccountExists(entity.AgencyNumber, entity.AccountNumber))
            {
                newAccount.ClientID = clientID;
                accountRepository.Insert(newAccount);

                accountCreate.Success = true;
            }
            else
            {
                accountCreate.Success = false;
                accountCreate.Errors.Add("Conta já existente");
            }

            accountCreate.Data = ClientConverter.Parse(newClient, newAccount);
            #endregion

            return(accountCreate);
        }
示例#25
0
 public void TestSetup()
 {
     converter = new AccountConverter();
 }
示例#26
0
 public IEnumerable <AccountDTO> getAllAccounts()
 {
     return(AccountConverter.toDtos(accountRepository.Get()));
 }
示例#27
0
        public Account GetParent(Guid id)
        {
            var parentId = Context.Opportunities.Single(o => o.Id == id).AccountId;

            return(AccountConverter.ToDomain(Context.Accounts.Single(a => a.Id == parentId)));
        }