Exemplo n.º 1
0
        internal Ordering.PurchaseOrderAccount Require(Ordering.PurchaseOrderAccount id)
        {
            var result = DataSession.Single <Ordering.PurchaseOrderAccount>(id);

            if (result == null)
            {
                throw new ItemNotFoundException("PurchaseOrderAccount", $"ClientID = {id.ClientID} and AccountID = {id.AccountID}");
            }

            return(result);
        }
Exemplo n.º 2
0
        private Account CreateAccount(Ordering.PurchaseOrderAccount poa)
        {
            var acct = Require <Data.Account>(x => x.AccountID, poa.AccountID);

            return(new Account()
            {
                ClientID = poa.ClientID,
                AccountID = acct.AccountID,
                AccountName = acct.Name,
                ShortCode = acct.ShortCode,
                Active = poa.Active
            });
        }
Exemplo n.º 3
0
        public Account AddOrUpdate(int clientId, int accountId)
        {
            var acct = new Ordering.PurchaseOrderAccount {
                AccountID = accountId, ClientID = clientId
            };

            var existing = DataSession.Single <Ordering.PurchaseOrderAccount>(acct);

            if (existing == null)
            {
                //insert new
                acct.Active = true;
                DataSession.Insert(acct);
                return(CreateAccount(acct));
            }
            else
            {
                //update existing
                existing.Active = true;
                return(CreateAccount(existing));
            }
        }