private void UpdateBranchDetails(BankPfmsCopy branch, BankMasterLocalContext context) { List <BranchDetailsByIFSCDto> branchList = new List <BranchDetailsByIFSCDto>(); //GetBankBranchByIFSC String xmlBranchStr = $"<BankBranchByIFSC><BankName>{branch.BankName}</BankName><IfscCode>{branch.IfscCode}</IfscCode></BankBranchByIFSC>"; var xmlBranchEle = GetElement(xmlBranchStr); try { BankService.FileReconcilationMessage_GetBankBranchByIFSC req = new BankService.FileReconcilationMessage_GetBankBranchByIFSC { Username = "******", Password = "******", ResponseMessage = xmlBranchEle }; BankService.FileReconcilationContractClient cc = new BankService.FileReconcilationContractClient(); var result = cc.PFMS_GetBankBranchByIFSCAsync(req).GetAwaiter().GetResult(); String xml = result.ResponseMessage.FirstChild.InnerXml; XElement doc = XElement.Parse(xml); var response = doc.Elements("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}BankBranchByIFSC"); foreach (var item in response) { String BranchId = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}BranchId").Value; String BankId = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}BankId").Value; String BankName = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}BankName").Value; String BranchCode = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}BranchCode").Value; String IFSCCode = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}IFSCCode").Value; String BranchAddress = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}BranchAddress").Value; String State = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}State").Value; String District = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}District").Value; String BankStatus = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}BankStatus").Value; String BranchStatus = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}BranchStatus").Value; String CreatedDate = item.Element("{http://webservices.pfms.nic.in/PFMSExternalWebService.xsd}CreatedDate").Value; var branchListItem = new BranchDetailsByIFSCDto(BranchId, BankId, BankName, BranchCode, IFSCCode, BranchAddress, State, District, BankStatus, BranchStatus, CreatedDate); branchList.Add(branchListItem); } //handle error cases //For more than one respose cases branchList.ForEach(b => { if (b.BranchId == branch.BranchId.ToString()) { UpdateIfChanges(b, context); } }); context.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex); } }
private void AddNewBranches(List <BranchDetailsByIFSCDto> newBranchList, BankMasterLocalContext context) { List <BankPfmsCopy> branchList = newBranchList.Select(b => new BankPfmsCopy { BankName = b.BankName, BranchId = int.Parse(b.BranchId), BranchName = b.BranchCode, State = b.State, District = b.District, IfscCode = b.IFSCCode, Address = b.BranchAddress, IsActive = b.BranchStatus == "Active"?true:false }).ToList(); BankPfmsCopy branch = branchList[0]; branch.IsModified = false; branch.IsChecked = false; context.Add(branch); context.SaveChanges(); }