示例#1
0
        private void InitializeConfigs()
        {
            csw = Container.Resolve<ICountryService>();
            lsw = Container.Resolve<ILocalService>();
            ssw = Container.Resolve<ISubdivisionService>();

            ConfigUser = new DefaultMapConfig();
                ConfigUserFullInfo = new DefaultMapConfig();
                ConfigUser.ConvertUsing((UserFullInfo usr) =>
                    new User
                    {
                        Id = usr.Id,
                        FirstName = usr.FirstName,
                        SecondName = usr.SecondName,
                        CountryId = usr.Country.Id,
                        LocationId = usr.Location.Id,
                        SubdivisionId = usr.Subdivision.Id
                    });

                ConfigUserFullInfo.ConvertUsing((User usr) =>
                    new UserFullInfo
                    {
                        Id = usr.Id,
                        FirstName = usr.FirstName,
                        SecondName = usr.SecondName,
                        Country = csw.GetCountryById(usr.CountryId),
                        Subdivision = usr.SubdivisionId != null ? ssw.GetSubdivisionById((int)usr.SubdivisionId) : null,
                        Location = usr.LocationId != null ? lsw.GetLocationById((int)usr.LocationId) : null

                    });
        }