コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 public static CustomerSourceOfIncome GetActive(Customer customer, SourceOfIncome sourceOfIncome)
 {
     return customer.CustomerSourceOfIncomes.FirstOrDefault(entity => entity.EndDate == null && entity.SourceOfIncomeId == sourceOfIncome.Id);
 }