Example #1
0
    public void GetCurrentUserContactAndCompanyNames(out string contactName, out string companyName)
    {
        companyName = contactName = string.Empty;

        var contact             = new Terrasoft.Configuration.Contact(UserConnection);
        var account             = new Terrasoft.Configuration.Account(UserConnection);
        var contactEntitySchema = UserConnection.EntitySchemaManager.GetInstanceByName("Contact");
        var contactEntitySchemaPrimaryColumnName = contactEntitySchema.GetPrimaryColumnName();
        var contactEntitySchemaPrimaryColumn     = contactEntitySchema.Columns.GetByName(contactEntitySchemaPrimaryColumnName);
        var accountEntitySchema = UserConnection.EntitySchemaManager.GetInstanceByName("Account");
        var accountEntitySchemaPrimaryColumnName = accountEntitySchema.GetPrimaryColumnName();
        var accountEntitySchemaPrimaryColumn     = accountEntitySchema.Columns.GetByName(accountEntitySchemaPrimaryColumnName);

        var nameColumnsToFetch = new EntitySchemaColumn[] {
            contactEntitySchema.Columns.GetByName("Name")
        };
        var nameAccountColumnsToFetch = new EntitySchemaColumn[] {
            contactEntitySchema.Columns.GetByName("Name"),
            contactEntitySchema.Columns.GetByName("Account")
        };
        var currentUserContactUId = UserConnection.CurrentUser.ContactId;

        if (contact.FetchFromDB(contactEntitySchemaPrimaryColumn, currentUserContactUId, nameAccountColumnsToFetch))
        {
            contactName = contact.Name;
            var currentUserCompanyUId = contact.AccountId;
            if (account.FetchFromDB(accountEntitySchemaPrimaryColumn, currentUserCompanyUId, nameColumnsToFetch))
            {
                companyName = account.Name;
            }
        }
    }
Example #2
0
 public Account(Terrasoft.Configuration.Account source)
     : base(source)
 {
     this.CopyEntityLookupProperties(source);
 }