/*
ref: https://aspnetboilerplate.com/Pages/Documents/Object-To-Object-Mapping
*/
/***********************************************************/
/* Mapper.Map<TSource, TDestination>(item) */
/***********************************************************/
var authAssign = await _authManager.GetAuthAssignAsync(id.Value);
entity = Mapper.Map<AuthAssignViewModel>(authAssign);
/*---------------------------------------------------------*/
var x = Mapper.Map(source, (Destination)null);
/*---------------------------------------------------------*/
var dbItem = _declarationLookUpManager.GetAllLookUp().Where(p => p.Id == model.Id).FirstOrDefault();
var item = Mapper.Map(model, dbItem);
/***********************************************************/
/* MapTo */
/***********************************************************/
public void CreateUser(CreateUserInput input)
{
var user = input.MapTo<User>();
_userRepository.Insert(user);
}
/*---------------------------------------------------------*/
public void UpdateUser(UpdateUserInput input)
{
var user = _userRepository.Get(input.Id);
input.MapTo(user);
}
/*---------------------------------------------------------*/
[AutoMapFrom(typeof(PolicyInsuredCoverage))]
[AutoMapTo(typeof(PolicyInsuredCoverage))]
public class PolicyInsuredCoverageDto : EntityDto
{
}
public List<PolicyInsuredCoverageDto> GetPolicyInsuredCoverageListByInsuredId(int insuredId)
{
List<PolicyInsuredCoverage> coverages =
_policyManager.GetPolicyInsuredCoveragesByPolicyInsuredId(insuredId).ToList();
return coverages.MapTo<List<PolicyInsuredCoverageDto>>();
}