public override APMC EntityDtoToEntity(APMCDto entityDto) { APMC apmc = Mapper.Map <APMCDto, APMC>(entityDto); if (entityDto != null) { #region Apmc Address apmc.Address = Mapper.Map <AddressDto, Address>(entityDto.Address); if (entityDto.Address != null) { if (entityDto.Address.CityVillage != null && entityDto.Address.CityVillage.CityVillageId != 0) { CityVillageService cityvillageService = new CityVillageService(); CityVillageDto cityvillageDto = cityvillageService.GetById(entityDto.Address.CityVillage.CityVillageId); apmc.Address.CityVillage = Mapper.Map <CityVillageDto, CityVillage>(cityvillageDto); } else { apmc.Address.CityVillage = Mapper.Map <CityVillageDto, CityVillage>(entityDto.Address.CityVillage); } } #endregion #region Apmc ContactDetails apmc.ContactNos.Clear(); if (entityDto.ContactNos != null) { foreach (ContactDetailsDto contactdetailsdto in entityDto.ContactNos) { ContactDetails apmccontactdetails = Mapper.Map <ContactDetailsDto, ContactDetails>(contactdetailsdto); apmc.ContactNos.Add(apmccontactdetails); } } #endregion #region APMC Of Clients apmc.APMCOfClients.Clear(); if (entityDto.APMCOfClients != null) { foreach (ClientDto clientDto in entityDto.APMCOfClients) { Client client = Mapper.Map <ClientDto, Client>(clientDto); apmc.APMCOfClients.Add(client); } } #endregion } return(apmc); }
public override Address EntityDtoToEntity(AddressDto entityDto) { Address address = Mapper.Map <AddressDto, Address>(entityDto); if (entityDto != null) { if (entityDto.CityVillage != null) { CityVillageService cityvillageService = new CityVillageService(); CityVillageDto cityvillageDto = cityvillageService.GetById(entityDto.CityVillage.CityVillageId); address.CityVillage = Mapper.Map <CityVillageDto, CityVillage>(cityvillageDto); } else { address.CityVillage = Mapper.Map <CityVillageDto, CityVillage>(entityDto.CityVillage); } } return(address); }
public override CityVillage EntityDtoToEntity(CityVillageDto entityDto) { CityVillage cityvillage = Mapper.Map <CityVillageDto, CityVillage>(entityDto); if (entityDto != null) { #region CityorVillage if (entityDto.CityVillageId != 0) { CityVillageService cvService = new CityVillageService(); CityVillageDto cvDto = cvService.GetById(entityDto.CityVillageId); bool isDirty = CityVillage.IsDirty(entityDto, cvDto); if (isDirty) { if (entityDto.CAId != null && (entityDto.CAId != cvDto.CAId)) { entityDto.CityVillageId = 0; entityDto.BaseCityVillageId = cvDto.CityVillageId; cityvillage = Mapper.Map <CityVillageDto, CityVillage>(entityDto); } else if (entityDto.CAId == cvDto.CAId) { cityvillage = Mapper.Map <CityVillageDto, CityVillage>(entityDto); } else { cityvillage = Mapper.Map <CityVillageDto, CityVillage>(cvDto); } } } #endregion #region District #region Old Code of DistrictOfCityVillage //if (entityDto.DistrictOfCityVillage != null) //{ // cityvillage.DistrictOfCityVillage = Mapper.Map<DistrictDto, District>(entityDto.DistrictOfCityVillage); // if(entityDto.DistrictOfCityVillage.StateOfDistrict != null) // { // cityvillage.DistrictOfCityVillage.StateOfDistrict = Mapper.Map<StateDto, State>(entityDto.DistrictOfCityVillage.StateOfDistrict); // if(entityDto.DistrictOfCityVillage.StateOfDistrict.StateInCountry!=null) // { // cityvillage.DistrictOfCityVillage.StateOfDistrict.StateInCountry = // Mapper.Map<CountryDto, Country>(entityDto.DistrictOfCityVillage.StateOfDistrict.StateInCountry); // } // } //} #endregion if (entityDto.DistrictOfCityVillage != null && entityDto.DistrictOfCityVillage.DistrictId != 0) { DistrictService districtservice = new DistrictService(); DistrictDto districtDto = districtservice.GetById(entityDto.DistrictOfCityVillage.DistrictId); cityvillage.DistrictOfCityVillage = Mapper.Map <DistrictDto, District>(districtDto); } else { cityvillage.DistrictOfCityVillage = Mapper.Map <DistrictDto, District>(entityDto.DistrictOfCityVillage); } #endregion #region Addresses cityvillage.Addresses.Clear(); if (entityDto.Addresses != null) { foreach (AddressDto addressdto in entityDto.Addresses) { Address address = new Address(); address = Mapper.Map <AddressDto, Address>(addressdto); cityvillage.Addresses.Add(address); } } #endregion } return(cityvillage); }
public override BankBranch EntityDtoToEntity(BankBranchDto entityDto) { BankBranch bankbranch = Mapper.Map <BankBranchDto, BankBranch>(entityDto); if (entityDto != null) { #region Branch if (entityDto.BranchId != 0) { BankBranchService branchservice = new BankBranchService(); BankBranchDto branchdto = branchservice.GetById(entityDto.BranchId); bool isDirty = BankBranch.IsDirty(entityDto, branchdto); if (isDirty) { if (entityDto.CAId != null && (entityDto.CAId != branchdto.CAId)) { entityDto.BranchId = 0; entityDto.BaseBranchId = branchdto.BranchId; entityDto.BranchAddress.AddressId = 0; entityDto.WeeklyOffDay.WeeklyOffDayId = 0; entityDto.WeeklyHalfDay.WeeklyHalfDayId = 0; if (entityDto.BranchContactNos != null) { foreach (ContactDetailsDto cddto in entityDto.BranchContactNos) { ContactDetails branchcontactdetails = new Entities.ContactDetails(); branchcontactdetails = Mapper.Map <ContactDetailsDto, ContactDetails>(cddto); bankbranch.BranchContactNos.Add(branchcontactdetails); } } bankbranch = Mapper.Map <BankBranchDto, BankBranch>(entityDto); } else if (entityDto.CAId == branchdto.CAId) { bankbranch = Mapper.Map <BankBranchDto, BankBranch>(entityDto); } else { bankbranch = Mapper.Map <BankBranchDto, BankBranch>(branchdto); } } } #endregion #region Bank if (entityDto.BranchOfBank != null && entityDto.BranchOfBank.BankId != 0) { BankService bankService = new BankService(); BankDto bankDto = bankService.GetById(entityDto.BranchOfBank.BankId); bankbranch.BranchOfBank = Mapper.Map <BankDto, Bank>(bankDto); } else { bankbranch.BranchOfBank = Mapper.Map <BankDto, Bank>(entityDto.BranchOfBank); } #endregion #region Branch Address if (entityDto.BranchAddress != null) { bankbranch.BranchAddress = Mapper.Map <AddressDto, Address>(entityDto.BranchAddress); if (entityDto.BranchAddress.CityVillage != null) { if (entityDto.BranchAddress.CityVillage.CityVillageId != 0) { CityVillageService cityvillageService = new CityVillageService(); CityVillageDto cityvillageDto = cityvillageService.GetById(entityDto.BranchAddress.CityVillage.CityVillageId); bankbranch.BranchAddress.CityVillage = Mapper.Map <CityVillageDto, CityVillage>(cityvillageDto); bankbranch.BranchAddress.CityVillage.DistrictOfCityVillage = Mapper.Map <DistrictDto, District>(cityvillageDto.DistrictOfCityVillage); bankbranch.BranchAddress.CityVillage.DistrictOfCityVillage.StateOfDistrict = Mapper.Map <StateDto, State>(cityvillageDto.DistrictOfCityVillage.StateOfDistrict); } else { bankbranch.BranchAddress.CityVillage = Mapper.Map <CityVillageDto, CityVillage>(entityDto.BranchAddress.CityVillage); } } } #endregion #region Branch Contacts bankbranch.BranchContactNos.Clear(); if (entityDto.BranchContactNos != null) { foreach (ContactDetailsDto contactdetailsdto in entityDto.BranchContactNos) { ContactDetails bankbranchcontactdetails = new Entities.ContactDetails(); bankbranchcontactdetails = Mapper.Map <ContactDetailsDto, ContactDetails>(contactdetailsdto); bankbranch.BranchContactNos.Add(bankbranchcontactdetails); } } #endregion #region Weekly HalfDay bankbranch.WeeklyHalfDay = Mapper.Map <WeeklyHalfDayDto, WeeklyHalfDay>(entityDto.WeeklyHalfDay); #endregion #region Weekly Offday bankbranch.WeeklyOffDay = Mapper.Map <WeeklyOffDaysDto, WeeklyOffDays>(entityDto.WeeklyOffDay); #endregion #region BranchOfClientSubscriptionPayment bankbranch.BranchOfClientSubscriptionPayment.Clear(); if (entityDto.BranchOfClientSubscriptionPayment != null) { foreach (ClientSubscriptionPaymentDetailsDto clientsubscriptionpaymentDto in entityDto.BranchOfClientSubscriptionPayment) { ClientSubscriptionPaymentDetails clientsubscriptionpayment = Mapper.Map <ClientSubscriptionPaymentDetailsDto, ClientSubscriptionPaymentDetails>(clientsubscriptionpaymentDto); bankbranch.BranchOfClientSubscriptionPayment.Add(clientsubscriptionpayment); } } #endregion #region BranchOfClientPartner bankbranch.BranchOfClientSubscriptionPayment.Clear(); if (entityDto.BranchOfClientPartner != null) { foreach (ClientPartnerBankDetailsDto clientpartnerbankDto in entityDto.BranchOfClientPartner) { ClientPartnerBankDetails clientpartnerbank = Mapper.Map <ClientPartnerBankDetailsDto, ClientPartnerBankDetails>(clientpartnerbankDto); bankbranch.BranchOfClientPartner.Add(clientpartnerbank); } } #endregion } return(bankbranch); }