public async Task <AgentRequestEdit> UpdateAgent([FromBody] AgentRequestEdit agentRequestEdit) { var agentResponse = await _agentService.UpdateAgent(agentRequestEdit); return(agentResponse); }
public async Task <AgentRequestEdit> UpdateAgent(AgentRequestEdit agentRequestEdit) { Agent agent = new Agent { AgentID = Convert.ToInt32(agentRequestEdit.AgentID), BusinessName = agentRequestEdit.BusinessName, City = agentRequestEdit.City, CompanyTIN = agentRequestEdit.Comptin, CorporateName = agentRequestEdit.CorpName, Country = agentRequestEdit.Country, CTCNo = agentRequestEdit.CTCNo, DailyDepositLimit = agentRequestEdit.DailyDepLimit, FirstName = agentRequestEdit.FirstName, IsBusiness = agentRequestEdit.IsBusinessName != null?bool.Parse(agentRequestEdit.IsBusinessName) : false, IsCorporate = agentRequestEdit.IsCorpName != null?bool.Parse(agentRequestEdit.IsCorpName) : false, IsMerchCategory = agentRequestEdit.IsMerchcategory != null?bool.Parse(agentRequestEdit.IsMerchcategory) : false, LastName = agentRequestEdit.LastName, LastUserUpdate = agentRequestEdit.User, MasterAgentCodeID = Convert.ToInt32(agentRequestEdit.Masteridlist), MerchantCategory = agentRequestEdit.Merchcategory, MiddleName = agentRequestEdit.MiddleName, PhoneNo = agentRequestEdit.PhoneNo, PostalCode = Convert.ToInt32(agentRequestEdit.PostalCode), RequestID = agentRequestEdit.RequestID, StreetNo = agentRequestEdit.StreetNo, SubAgentCodeID = Convert.ToInt32(agentRequestEdit.SubmasterAgentCode), Town = agentRequestEdit.Town, UpdateDeteTime = DateTime.Now, Status = "Pending", IsDeleted = false }; Bank bank = new Bank { BankAccountName = agentRequestEdit.Bankaccname, City = agentRequestEdit.BCity, Country = agentRequestEdit.BCountry, DepositoryBank = agentRequestEdit.DepBank, LastUserUpdate = agentRequestEdit.User, PostalCode = Convert.ToInt32(agentRequestEdit.BPostalCode), RBOContactNo = agentRequestEdit.RBOContactNo, RBOEmailAdd = agentRequestEdit.RBOEmailAdd, RBOFName = agentRequestEdit.RBOFirstName, RBOLName = agentRequestEdit.RBOLastName, RBOMName = agentRequestEdit.RBOMiddleName, RBOType = agentRequestEdit.RBOType, RequestID = agentRequestEdit.RequestID, StreetNo = agentRequestEdit.BStreetNo, Town = agentRequestEdit.BTown, UpdateDeteTime = DateTime.Now, IsDeleted = false }; Contact contact = new Contact { BillingContactNo = agentRequestEdit.CBillContactNo, BillingFirstName = agentRequestEdit.CBillFName, BillingLastName = agentRequestEdit.CBillLName, BillingMiddleName = agentRequestEdit.CBillMName, ContactNo = agentRequestEdit.CContactno, Department = agentRequestEdit.CDepartment, Designation = agentRequestEdit.CDesignation, EmailAddress = agentRequestEdit.CEmailAdd, FaxNo = agentRequestEdit.CFaxno, FirstName = agentRequestEdit.CFirstName, LastName = agentRequestEdit.CLastName, LastUserUpdate = agentRequestEdit.User, MiddleName = agentRequestEdit.CMiddleName, RequestID = agentRequestEdit.RequestID, UpdateDeteTime = DateTime.Now, IsDeleted = false }; for (int i = 0; i < agentRequestEdit.AgentBranches?.Count(); i++) { if (i == 0) { await _agentRepository.DeleteAgentBranches(agentRequestEdit.RequestID); } AgentBranches agentBranches = new AgentBranches { RequestID = agentRequestEdit.RequestID, AgentBranchName = agentRequestEdit.AgentBranches[i].ABranchName, StreetNo = agentRequestEdit.AgentBranches[i].AStreetNo, Town = agentRequestEdit.AgentBranches[i].ATown, City = agentRequestEdit.AgentBranches[i].ACity, Country = agentRequestEdit.AgentBranches[i].Acountry, PostalCode = Convert.ToInt32(agentRequestEdit.AgentBranches[i].APostalCode), PhoneNo = agentRequestEdit.AgentBranches[i].APhoneNo, CreatedDateTime = DateTime.Now, UserCreate = agentRequestEdit.User, LastUserUpdate = agentRequestEdit.User, UpdateDeteTime = DateTime.Now, IsDeleted = false }; var agentBranchesResponse = await _agentRepository.UpdateAgentBranches(agentBranches); } for (int i = 0; i < agentRequestEdit.Terminal?.Count(); i++) { if (i == 0) { await _agentRepository.DeleteTerminal(agentRequestEdit.RequestID); } Terminal terminal = new Terminal { RequestID = agentRequestEdit.RequestID, POSTerminalName = agentRequestEdit.Terminal[i].TerminalName, TypeOfPOSTerminal = agentRequestEdit.Terminal[i].TerminalType, CreatedDateTime = DateTime.Now, UserCreate = agentRequestEdit.User, LastUserUpdate = agentRequestEdit.User, UpdateDeteTime = DateTime.Now, IsDeleted = false, TerminalID = agentRequestEdit.Terminal[i].TerminalID, MerchantID = agentRequestEdit.Terminal[i].MerchantID, }; var terminalResponse = await _agentRepository.UpdateTerminal(terminal); } for (int i = 0; i < agentRequestEdit.Auth?.Count(); i++) { if (i == 0) { await _agentRepository.DeleteMoa(agentRequestEdit.RequestID); } Moa moa = new Moa { AuthDesignation = agentRequestEdit.Auth[i].AuthDesignation, AuthFirstName = agentRequestEdit.Auth[i].AuthFirstName, AuthID = await CreateAgentID(), AuthLastName = agentRequestEdit.Auth[i].AuthLastName, AuthMiddleName = agentRequestEdit.Auth[i].AuthMiddleName, LastUserUpdate = agentRequestEdit.User, RequestID = agentRequestEdit.RequestID, UpdateDeteTime = DateTime.Now, ValidIDExpdate = agentRequestEdit.Auth[i].ValidIDExpdate, ValidIDNumber = agentRequestEdit.Auth[i].ValidIDNo, ValidIDType = agentRequestEdit.Auth[i].ValidIDType, CreatedDateTime = DateTime.Now, UserCreate = agentRequestEdit.User }; var moaResponse = await _agentRepository.UpdateMoa(moa); } for (int i = 0; i < agentRequestEdit.BankFeesList?.Count(); i++) { if (i == 0) { await _agentRepository.DeleteBankFees(agentRequestEdit.RequestID); } BankFees bankFees = new BankFees { RequestID = agentRequestEdit.RequestID, AgentID = Convert.ToInt32(agentRequestEdit.AgentID), MerchantID = agentRequestEdit.MerchantID, TransactionType = agentRequestEdit.BankFeesList[i].TransName, ConvenienceFee = agentRequestEdit.BankFeesList[i].ConvFee, Quota = null, CreatedDateTime = DateTime.Now, UserCreate = agentRequestEdit.User, LastUserUpdate = agentRequestEdit.User, UpdateDeteTime = DateTime.Now, IsDeleted = false }; var bankResponse = await _agentRepository.UpdateBankFees(bankFees); } var agentResponse = await _agentRepository.UpdateAgent(agent, bank, contact); return(agentRequestEdit); }