示例#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);
        }
示例#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
            });
        }
示例#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));
            }
        }