コード例 #1
0
        public Contoso.Apps.Insurance.Data.DTOs.Person GetPerson(int id)
        {
            Contoso.Apps.Insurance.Data.DTOs.Person person;

            using (var ctx = new ContosoInsuranceContext())
            {
                person = PersonMapping.MapEntityToDto(ctx.People.FirstOrDefault(p => p.Id == id));
            }

            return(person);
        }
コード例 #2
0
        // GET api/people/5
        public Data.DTOs.Person GetPerson(int id)
        {
            Data.DTOs.Person person;

            using (var ctx = new ContosoInsuranceContext(_connectionString))
            {
                person = PersonMapping.MapEntityToDto(ctx.People.FirstOrDefault(p => p.Id == id));
            }

            return(person);
        }
コード例 #3
0
ファイル: DependentMapping.cs プロジェクト: DevJulitogtu/temp
        public static DTOs.Dependent MapEntityToDto(Dependent source)
        {
            var destination = new DTOs.Dependent
            {
                Id               = source.Id,
                Active           = source.Active,
                PersonId         = source.PersonId,
                PolicyHolderId   = source.PolicyHolderId,
                PolicyHolderName = $"{source.PolicyHolder?.Person?.LName}, {source.PolicyHolder?.Person?.FName}"
            };

            //if (source.PolicyHolder != null)
            //{
            //    destination.PolicyHolder = PolicyHolderMapping.MapEntityToDto(source.PolicyHolder);
            //}

            if (source.Person != null)
            {
                destination.Person = PersonMapping.MapEntityToDto(source.Person);
            }

            return(destination);
        }