I was just curious if I should put my age method into my POCO class or leave this method in my business layer.
Right now I have 4 layers:
- BusinessObject(BO)
- Data Acess Layer(DAL)
- UserInterface(UI)
- Service.
Right now I want to query users with age older than 13 years old. So I am debating if should have a method in my POCO class in BO which return the current age of users, or should I query the DOB from my business layer as follow
BO
public class Person:Base
{
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public DateTime DOB { get; set; }
public int Age
{
get
{
DateTime today = DateTime.Today;
int age = today.Year - DOB.Year;
return age;
}
}
}
Business Layer
public class PersonBLL
{
private PersonDAL db = null;
public PersonBLL()
{
db = new PersonDAL(new AppContext());
}
public IEnumerable<Person> PersonGEAge(int age)
{
DateTime td = DateTime.Now;
DateTime birthday = DateTime.Now;
DateTime date = new DateTime(birthday.Year - age, td.Month, td.Day, 4, 5, 6);
return db.PersonDOB(date);
}
}