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); }
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 }); }
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)); } }