I'm using EntityFramework as my DAL, where I have for example entity:
public class UserEntity
{
public int WorkingDays {get;set;}
public int PayPerDay {get;set;}
}
I'm getting this entity in my services layer by repository, and that's the place i need to calculate for example his salary:
public ???? GetUserWithPayments(int id)
{
var userEntity = _userRepository.GetUser(id);
var salary = userEntity.WorkingDays * userEntity.PayPerDay;
//*what should i return??*//
}
And now I have no idea what should I return from this method? I see 2 options:
1.) Add salary field to UserEntity, and returns UserEntity. This field will be skipped when I save UserEntity to database.
2.) Create UserDto with UserEntity fields and one more Salary
This service is called by UserController where the result will be mapped to GetUserDetailsViewModel
Aucun commentaire:
Enregistrer un commentaire