public void OnCreated() { if (PrimaryAddress == null) { PrimaryAddress = ObjectSpace.CreateObject <Address>(); } LeadHistoryRecord historyRecord = ObjectSpace.CreateObject <LeadHistoryRecord>(); historyRecord.SaleStage = SaleStage.Lead; LeadHistoryRecords.Add(historyRecord); }
public LeadHistoryRecord FindLeadHistoryRecord(SaleStage saleStage) { List <LeadHistoryRecord> historyRecords = new List <LeadHistoryRecord>(LeadHistoryRecords); LeadHistoryRecord result = null; foreach (LeadHistoryRecord record in historyRecords) { if (record.SaleStage == saleStage) { if (result != null) { throw new InvalidOperationException("Lead history item is duplicated."); } result = record; } } return(result); }
public static void UpdateHistory(ISaleStageHistoryTarget saleStageHistoryTarget, IObjectSpace os) { if (saleStageHistoryTarget.History != null) { bool addHistoryRecord = true; foreach (LeadHistoryRecord historyRecord in saleStageHistoryTarget.History.LeadHistoryRecords) { if (historyRecord.SaleStage == saleStageHistoryTarget.SaleStage) { addHistoryRecord = false; } } if (addHistoryRecord) { LeadHistoryRecord historyRecord = os.CreateObject <LeadHistoryRecord>(); historyRecord.SaleStage = saleStageHistoryTarget.SaleStage; saleStageHistoryTarget.History.LeadHistoryRecords.Add(historyRecord); } } }