Beispiel #1
0
        private Account FindOrCreate(string name)
        {
            var account = _accountStore.GetAll()
                          .SingleOrDefault(a => a.CompanyId == _companyId && a.Description == name);

            if (account == null)
            {
                account = new Account
                {
                    CompanyId   = _companyId,
                    CreatedOn   = DateTime.Now,
                    CreatedBy   = "IMPORT",
                    Balance     = 0,
                    Description = name,
                };

                _accountStore.Save(account);
                account = _accountStore.Get(account.AccountId);
            }

            return(account);
        }