public static CustomerSourceOfIncome Create(SourceOfIncome sourceOfIncome, Customer customer, DateTime today)
        {
            CustomerSourceOfIncome customerSourceOfIncome = new CustomerSourceOfIncome();
            customerSourceOfIncome.Customer = customer;
            customerSourceOfIncome.EffectiveDate = today;
            customerSourceOfIncome.SourceOfIncome = sourceOfIncome;

            Context.CustomerSourceOfIncomes.AddObject(customerSourceOfIncome);
            return customerSourceOfIncome;
        }
        public static CustomerSourceOfIncome CreateOrUpdate(SourceOfIncome sourceOfIncome, Customer customer, DateTime today)
        {
            CustomerSourceOfIncome current = GetActive(customer, sourceOfIncome);
            if (current != null)
                current.EndDate = today;

            CustomerSourceOfIncome customerSourceOfIncome = new CustomerSourceOfIncome();
            customerSourceOfIncome.Customer = customer;
            customerSourceOfIncome.EffectiveDate = today;
            customerSourceOfIncome.SourceOfIncome = sourceOfIncome;

            Context.CustomerSourceOfIncomes.AddObject(customerSourceOfIncome);
            return customerSourceOfIncome;
        }
 public static CustomerSourceOfIncome GetActive(Customer customer, SourceOfIncome sourceOfIncome)
 {
     return customer.CustomerSourceOfIncomes.FirstOrDefault(entity => entity.EndDate == null && entity.SourceOfIncomeId == sourceOfIncome.Id);
 }