XCRM: Leads and opportunities

XAF Team Blog
03 October 2008

This post may be outdated. For the latest Domain Components concepts and examples refer to the current online documentation.

This post is one in a series about our work on Domain Components (DC) framework and related component libraries. I’m just describing what we are working on, what problems we are facing and what results we've got so far.

A Lead is not directly linked to a Contact or Account. It can be converted into an Account, Contact or Opportunity later. I’ll just capture the fact that the Lead class exists and may have some basic info:

[Test]
public void LeadsRelationships() {
    RegisterDC<ILead>();
    Generate();
    ILead romanFromDx = ObjectSpace.CreateObject<ILead>();
    romanFromDx.FirstName = "Roman";
    romanFromDx.LastName = "Eremin";
    romanFromDx.CompanyName = "DevExpress";
}
[DomainComponent]
public interface ILead {
    string FirstName { get; set; }
    string LastName { get; set; }
    string CompanyName { get; set; }
}

At this point, I’m not sure that the ILead should be inherited from the IPerson. So, I've just added the FirstName and LastName properties, and made a note to resolve this problem later.

An Opportunity is a more probable possibility for business. It is related to an Account (who you want to sell to) and Product (what you want to sell). Simple CRM systems do not track products and prices, so I will leave them out in our CRM app. Here is the test for Opportunities:

[Test]
public void OpportunityAccountRelationships() {
    RegisterDC<IContact>();
    RegisterDC<IAccount>();
    RegisterDC<IOpportunity>();
    Generate();
    IAccount dx = ObjectSpace.CreateObject<IAccount>();
    dx.Name = "DevExpress";
    IOpportunity sellComponents = ObjectSpace.CreateObject<IOpportunity>();
    sellComponents.Name = "Sell some third-party components to DX";
    sellComponents.Account = dx;
    Assert.IsTrue(Enumerator.Exists<IOpportunity>(dx.Opportunities, sellComponents));
}

To make this test pass I need the following:

[DomainComponent]
public interface IOpportunity {
    string Name { get; set; }
    IAccount Account { get; set; }
}
[DomainComponent]
public interface IAccount {
    
    IList<IOpportunity> Opportunities { get; }
}

Tags
2 comment(s)
drew..
drew..

slightly off-topic, but Roman, by repeating the same text as the first sentences of each of these blogs, the blog listing repeats the same lines over and over. If this was moved to be the second paragraph and an appropriate summary places as the first line(s).. this will aid the blog listings..   just a thought.. cheers. drew..

5 October, 2008
Alex Hoffman
Alex Hoffman

Just for those outside of the USA and new to CRM's, an "Account" is simply an "Organisation", and typically renamed as such.

5 October, 2008

Please login or register to post comments.