public void ConvertTo(PhysicalEntityView physicalEntityView, PhysicalEntity physicalEntity) { physicalEntity.PhysicalEntityPK = physicalEntityView.PhysicalEntityPK; physicalEntity.Firstname = physicalEntityView.Firstname; physicalEntity.Lastname = physicalEntityView.Lastname; physicalEntity.Gender = physicalEntityView.Gender; physicalEntity.OIB = physicalEntityView.OIB; physicalEntity.JMBG = physicalEntityView.JMBG; physicalEntity.DateOfBirth = physicalEntityView.DateOfBirth; physicalEntity.CitizenshipFK = physicalEntityView.CitizenshipFK; physicalEntity.BirthCountryFK = physicalEntityView.BirthCountryFK; physicalEntity.BirthCountyFK = physicalEntityView.BirthCountyFK; physicalEntity.BirthCityCommunityFK = physicalEntityView.BirthCityCommunityFK; physicalEntity.BirthPlace = physicalEntityView.BirthPlace; physicalEntity.ResidenceCountryFK = physicalEntityView.ResidenceCountryFK; physicalEntity.ResidenceCountyFK = physicalEntityView.ResidenceCountyFK; physicalEntity.ResidenceCityCommunityFK = physicalEntityView.ResidenceCityCommunityFK; physicalEntity.ResidencePostalOfficeFK = physicalEntityView.ResidencePostalOfficeFK; physicalEntity.ResidencePlaceFK = physicalEntityView.ResidencePlaceFK; physicalEntity.ResidencePlace = physicalEntityView.ResidencePlace; physicalEntity.ResidenceStreetName = physicalEntityView.ResidenceStreetName; physicalEntity.IdentityCardNumber = physicalEntityView.IdentityCardNumber; physicalEntity.IdentityCardDateOfIssue = physicalEntityView.IdentityCardDateOfIssue; physicalEntity.IdentityCardRegionalOfficeFK = physicalEntityView.IdentityCardRegionalOfficeFK; physicalEntity.IdentityCardDateTillValid = physicalEntityView.IdentityCardDateTillValid; physicalEntity.PassportNumber = physicalEntityView.PassportNumber; physicalEntity.PassportDateOfIssue = physicalEntityView.PassportDateOfIssue; physicalEntity.PassportDateTillValid = physicalEntityView.PassportDateTillValid; physicalEntity.PassportCountryOfIssueFK = physicalEntityView.PassportCountryOfIssueFK; physicalEntity.PassportPlaceOfIssue = physicalEntityView.PassportPlaceOfIssue; physicalEntity.ReferentRegionalOfficeFK = physicalEntityView.ReferentRegionalOfficeFK; physicalEntity.ReferentSubstationFK = physicalEntityView.ReferentSubstationFK; physicalEntity.Owner = physicalEntityView.Owner; physicalEntity.LegalRepresentative = physicalEntityView.LegalRepresentative; physicalEntity.Referent = physicalEntityView.Referent; physicalEntity.ChangeDate = physicalEntityView.ChangeDate; physicalEntity.Deleted = physicalEntityView.Deleted; }
public void BindDDLs(PhysicalEntityView physicalEntityView, ObjectContext db) { //countries ddl ICountriesRepository countriesRepository = new CountriesRepository(db); physicalEntityView.Citizenships = new SelectList(countriesRepository.GetCitizenships().ToList(), "CountryPK", "Citizenship"); physicalEntityView.BirthCountries = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name"); physicalEntityView.ResidenceCountries = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name"); physicalEntityView.PassportCountriesOfIssue = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name"); //counties ddl if (physicalEntityView.BirthCountryFK != null) { ICountiesRepository countiesRepository = new CountiesRepository(db); physicalEntityView.BirthCounties = new SelectList(countiesRepository.GetCountiesByCountry(Convert.ToInt32(physicalEntityView.BirthCountryFK)), "CountyPK", "Name", physicalEntityView.BirthCountyFK); } else { physicalEntityView.BirthCounties = new SelectList(new List <County>(), "CountyPK", "Name"); } if (physicalEntityView.ResidenceCountryFK != null) { ICountiesRepository countiesRepository = new CountiesRepository(db); physicalEntityView.ResidenceCounties = new SelectList(countiesRepository.GetCountiesByCountry(Convert.ToInt32(physicalEntityView.ResidenceCountryFK)), "CountyPK", "Name", physicalEntityView.ResidenceCountyFK); } else { physicalEntityView.ResidenceCounties = new SelectList(new List <County>(), "CountyPK", "Name"); } //citiesCommunities ddl if (physicalEntityView.BirthCountyFK != null) { ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(db); physicalEntityView.BirthCitiesCommunities = new SelectList(citiesCommunitiesRepository.GetCitiesCommunitiesByCounty(Convert.ToInt32(physicalEntityView.BirthCountyFK)), "CityCommunityPK", "Name", physicalEntityView.BirthCityCommunityFK); } else { physicalEntityView.BirthCitiesCommunities = new SelectList(new List <CityCommunity>(), "CityCommunityPK", "Name"); } if (physicalEntityView.ResidenceCountyFK != null) { ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(db); physicalEntityView.ResidenceCitiesCommunities = new SelectList(citiesCommunitiesRepository.GetCitiesCommunitiesByCounty(Convert.ToInt32(physicalEntityView.ResidenceCountyFK)), "CityCommunityPK", "Name", physicalEntityView.ResidenceCityCommunityFK); } else { physicalEntityView.ResidenceCitiesCommunities = new SelectList(new List <CityCommunity>(), "CityCommunityPK", "Name"); } //postal offices if (physicalEntityView.ResidenceCountyFK != null) { IPostalOfficesRepository postalOfficesRepository = new PostalOfficesRepository(db); var postalOffices = postalOfficesRepository.GetValidByCounty(Convert.ToInt32(physicalEntityView.ResidenceCountyFK)).OrderBy(c => c.Name); physicalEntityView.ResidencePostalOffices = new SelectList(postalOffices.Select(c => new { value = c.PostalOfficePK, text = c.Name + " (" + SqlFunctions.StringConvert((double)c.Number).Trim() + ")" }), "value", "text", physicalEntityView.ResidencePostalOfficeFK); } else { physicalEntityView.ResidencePostalOffices = new SelectList(new List <PostalOffice>(), "PostalOfficePK", "Name"); } //places if (physicalEntityView.ResidencePostalOfficeFK != null) { IPlacesRepository placesRepository = new PlacesRepository(db); physicalEntityView.ResidencePlaces = new SelectList(placesRepository.GetPlacesByPostalOffice(Convert.ToInt32(physicalEntityView.ResidencePostalOfficeFK)), "PlacePK", "Name", physicalEntityView.ResidencePlaceFK); } else { physicalEntityView.ResidencePlaces = new SelectList(new List <Place>(), "PlacePK", "Name"); } //regional offices ddl IRegionalOfficesRepository regionalOfficesView = new RegionalOfficesRepository(db); physicalEntityView.IdentityCardRegionalOffices = new SelectList(regionalOfficesView.GetValid().ToList(), "RegionalOfficePK", "Name", physicalEntityView.IdentityCardRegionalOfficeFK); physicalEntityView.ReferentRegionalOffices = new SelectList(regionalOfficesView.GetValid().ToList(), "RegionalOfficePK", "Name", physicalEntityView.ReferentRegionalOfficeFK); //substations if (physicalEntityView.ReferentRegionalOfficeFK != null) { ISubstationsRepository substationsRepository = new SubstationsRepository(db); physicalEntityView.ReferentSubstations = new SelectList(substationsRepository.GetValidByRegionalOffice(Convert.ToInt32(physicalEntityView.ReferentRegionalOfficeFK)), "SubstationPK", "Name", physicalEntityView.ReferentSubstationFK); } else { physicalEntityView.ReferentSubstations = new SelectList(new List <Place>(), "SubstationPK", "Name"); } // genders dll physicalEntityView.Genders = new SelectList(GeneratorView.GenerateGenders(), "Value", "Text"); }