Consider a service which updates PersonDetail tables in database. I am Using EF which maps the table to this Entity. When a record is updated, it is not actually updated but a new record is created and old one is made history by setting HistoryCode to 0
Class PersonDetail
{
int age;
Date birthDate;
DateTime effectiveDate;
int sequenceNumber; //An incremental number.
int HistoryCode; //0 represents history record and 1 current record
}
Now we have a service that updates the person details
if(newPersonDetail.effectiveDate < currentPersonDetails.effectiveDate)
{
//update sequence number of currentPersonDetails by 1
//insert a new Person Details record and assign its sequenceNumber as the sequence number
//of currentPersonDetails and HistoryCode as 0 to represent this is an history record
}
else
{
//Make the currentPersonDetails HistoryCode to 0 from 1
//Insert a newPersonDetail with sequence number incremented by 1 and HistoryCode set to 0
}
Logic? I am trying to move the data-access logic out of service layer to repository layer but not able to clearly figure out what part of this is considered as business logic and what is considered as Data Access logic.