public override WeeklyOffDays EntityDtoToEntity(WeeklyOffDaysDto entityDto) { WeeklyOffDays offday = Mapper.Map <WeeklyOffDaysDto, WeeklyOffDays>(entityDto); if (entityDto != null) { if (entityDto.WeeklyOffDayOfBranch != null && entityDto.WeeklyOffDayOfBranch.BranchId != 0) { BankBranchService bankbranchService = new BankBranchService(); BankBranchDto bankbranchDto = bankbranchService.GetById(entityDto.WeeklyOffDayOfBranch.BranchId); offday.WeeklyOffDayOfBranch = Mapper.Map <BankBranchDto, BankBranch>(bankbranchDto); } else { offday.WeeklyOffDayOfBranch = Mapper.Map <BankBranchDto, BankBranch>(entityDto.WeeklyOffDayOfBranch); } } return(offday); }
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); }