コード例 #1
0
        private UserProfileModel ToUserProfileModel(ParentBiography biography, ParentProfileModel profile)
        {
            var model = new UserProfileModel
            {
                Usi         = profile.Parent.ParentUsi,
                UniqueId    = profile.Parent.ParentUniqueId,
                FirstName   = profile.ParentProfile.FirstName,
                MiddleName  = profile.ParentProfile.MiddleName,
                LastSurname = profile.ParentProfile.LastSurname,
                Nickname    = profile.ParentProfile.NickName,
                PreferredMethodOfContactTypeId = profile.ParentProfile.PreferredMethodOfContactTypeId,
                ReplyExpectations = profile.ParentProfile.ReplyExpectations,
                LanguageCode      = profile.ParentProfile.LanguageCode,
                Addresses         = profile.ParentProfile.ParentProfileAddresses.Select(x => new AddressModel
                {
                    AddressTypeId            = x.AddressTypeDescriptorId,
                    StreetNumberName         = x.StreetNumberName,
                    ApartmentRoomSuiteNumber = x.ApartmentRoomSuiteNumber,
                    City = x.City,
                    StateAbbreviationTypeId = x.StateAbbreviationDescriptorId,
                    PostalCode = x.PostalCode
                }).ToList(),
                ElectronicMails = profile.ParentProfile.ParentProfileElectronicMails.Select(x => new ElectronicMailModel
                {
                    ElectronicMailAddress        = x.ElectronicMailAddress,
                    ElectronicMailTypeId         = x.ElectronicMailTypeDescriptorId,
                    PrimaryEmailAddressIndicator = x.PrimaryEmailAddressIndicator
                }).ToList(),
                TelephoneNumbers = profile.ParentProfile.ParentProfileTelephones.Select(x => new TelephoneModel
                {
                    TelephoneNumber = x.TelephoneNumber,
                    TextMessageCapabilityIndicator = x.TextMessageCapabilityIndicator,
                    TelephoneNumberTypeId          = x.TelephoneNumberTypeDescriptorId,
                    PrimaryMethodOfContact         = x.PrimaryMethodOfContact,
                    TelephoneCarrierTypeId         = x.TelephoneCarrierTypeId,
                    SMSDomain = x.TextMessageCarrierType?.SmsSuffixDomain
                }).ToList()
            };

            if (biography != null)
            {
                model.FunFact        = biography.FunFact;
                model.ShortBiography = biography.ShortBiography;
                model.Biography      = biography.Biography;
            }

            return(model);
        }
コード例 #2
0
        private UserProfileModel ToUserProfileModel(Parent edfiPerson, ParentBiography parentBiography)
        {
            var model = new UserProfileModel
            {
                Usi         = edfiPerson.ParentUsi,
                UniqueId    = edfiPerson.ParentUniqueId,
                FirstName   = edfiPerson.FirstName,
                MiddleName  = edfiPerson.MiddleName,
                LastSurname = edfiPerson.LastSurname,

                Addresses = edfiPerson.ParentAddresses.Select(x => new AddressModel
                {
                    AddressTypeId            = x.AddressTypeDescriptorId,
                    StreetNumberName         = x.StreetNumberName,
                    ApartmentRoomSuiteNumber = x.ApartmentRoomSuiteNumber,
                    City = x.City,
                    StateAbbreviationTypeId = x.StateAbbreviationDescriptorId,
                    PostalCode = x.PostalCode
                }).ToList(),
                ElectronicMails = edfiPerson.ParentElectronicMails.Select(x => new ElectronicMailModel
                {
                    ElectronicMailAddress        = x.ElectronicMailAddress,
                    ElectronicMailTypeId         = x.ElectronicMailTypeDescriptorId,
                    PrimaryEmailAddressIndicator = x.PrimaryEmailAddressIndicator
                }).ToList(),
                TelephoneNumbers = edfiPerson.ParentTelephones.Select(x => new TelephoneModel
                {
                    TelephoneNumber = x.TelephoneNumber,
                    TextMessageCapabilityIndicator = x.TextMessageCapabilityIndicator,
                    TelephoneNumberTypeId          = x.TelephoneNumberTypeDescriptorId
                }).ToList()
            };

            if (parentBiography != null)
            {
                model.FunFact        = parentBiography.FunFact;
                model.ShortBiography = parentBiography.ShortBiography;
                model.Biography      = parentBiography.Biography;
            }

            return(model);
        }
コード例 #3
0
        private async Task <ParentBiography> SaveParentBiographyAsync(int parentUsi, UserProfileModel model)
        {
            var parent = await _edFiDb.Parents.SingleOrDefaultAsync(p => p.ParentUsi == parentUsi);

            // Check if model has values, if not, dont save biography
            if (model.Biography == null && model.ShortBiography == null && model.FunFact == null)
            {
                return(null);
            }
            // Fetch current biography if any.
            var biography = await _edFiDb.ParentBiographies
                            .SingleOrDefaultAsync(x => x.ParentUniqueId == parent.ParentUniqueId);

            // If its a new one.
            if (biography == null)
            {
                biography = new ParentBiography
                {
                    ParentUniqueId = parent.ParentUniqueId,
                    FunFact        = model.FunFact,
                    ShortBiography = model.ShortBiography,
                    Biography      = model.Biography,
                };

                _edFiDb.ParentBiographies.Add(biography);
            }
            else
            { // We are updating
                biography.FunFact        = model.FunFact;
                biography.ShortBiography = model.ShortBiography;
                biography.Biography      = model.Biography;
            }

            // Persist changes to db.
            await _edFiDb.SaveChangesAsync();

            return(biography);
        }