public ClaimDto Map(Claim claim) { var claimDto = claim.Adapt <ClaimDto>(); claimDto.ClaimAdress = new AdressDto(); claimDto.ClaimAdress = claim.Adress.Adapt <AdressDto>(); claimDto.State = claim.State.Adapt <ClaimStateDto>(); return(claimDto); }
public ClaimDB Map(Claim claim) { var claimDb = claim.Adapt <ClaimDB>(); if (claimDb == null) { return(claimDb); } if (claim.Adress != null) { claimDb.Adress = new AdressDB(); claimDb.Adress = claim.Adress.Adapt <AdressDB>(); } if (claim.State != null) { claimDb.State = null; claimDb.StateId = claim.StateId; } if (claim.ClaimInsuredPersons != null && claim.ClaimInsuredPersons.Any()) { claimDb.ClaimInsuredPersons = new List <ClaimInsuredPersonDB>(); claim.ClaimInsuredPersons.ForEach(person => { ClaimInsuredPersonDB claimInsured = ClaimInsuredPersonDB.NewInstance(); claimInsured.Person = person.Adapt <PersonDB>(); if (person.Id > 0) { claimInsured.PersonId = person.Id; } if (claimDb.Id > 0) { claimInsured.ClaimId = claimDb.Id; } claimDb.ClaimInsuredPersons.Add(claimInsured); }); } if (claim.ClaimThirdInsuredPersons != null && claim.ClaimThirdInsuredPersons.Any()) { claimDb.ClaimThirdInsuredPersons = new List <ClaimThirdInsuredPersonDB>(); claim.ClaimThirdInsuredPersons.ForEach(person => { ClaimThirdInsuredPersonDB claimThirdInsured = ClaimThirdInsuredPersonDB.NewInstance(); claimThirdInsured.Person = person.Adapt <PersonDB>(); if (person.Id > 0) { claimThirdInsured.PersonId = person.Id; } if (claimDb.Id > 0) { claimThirdInsured.ClaimId = claimDb.Id; } claimDb.ClaimThirdInsuredPersons.Add(claimThirdInsured); }); } if (claim.ClaimInsuredVehicles != null && claim.ClaimInsuredVehicles.Any()) { claimDb.ClaimInsuredVehicles = new List <ClaimInsuredVehicleDB>(); claim.ClaimInsuredVehicles.ForEach(vehicle => { ClaimInsuredVehicleDB claimVehicle = ClaimInsuredVehicleDB.NewInstance(); claimVehicle.Vehicle = vehicle.Adapt <VehicleDB>(); if (vehicle.Id > 0) { claimVehicle.VehicleId = vehicle.Id; } if (claimDb.Id > 0) { claimVehicle.ClaimId = claimDb.Id; } claimDb.ClaimInsuredVehicles.Add(claimVehicle); }); } if (claim.ClaimThirdInsuredVehicles != null && claim.ClaimThirdInsuredVehicles.Any()) { claimDb.ClaimThirdInsuredVehicles = new List <ClaimThirdInsuredVehicleDB>(); claim.ClaimThirdInsuredVehicles.ForEach(vehicle => { ClaimThirdInsuredVehicleDB claimThirdVehicle = ClaimThirdInsuredVehicleDB.NewInstance(); claimThirdVehicle.Vehicle = vehicle.Adapt <VehicleDB>(); if (vehicle.Id > 0) { claimThirdVehicle.VehicleId = vehicle.Id; } if (claimDb.Id > 0) { claimThirdVehicle.ClaimId = claimDb.Id; } claimDb.ClaimThirdInsuredVehicles.Add(claimThirdVehicle); }); } if (claim.ClaimMessages != null && claim.ClaimMessages.Any()) { claimDb.ClaimMessages = new List <ClaimMessageDB>(); claim.ClaimThirdInsuredVehicles.ForEach(claimMessage => { claimDb.ClaimMessages.Add(claimMessage.Adapt <ClaimMessageDB>()); }); } return(claimDb); }