public async Task <Moa> UpdateMoa(Moa moa) { try { await _context.Database.ExecuteSqlCommandAsync("dbo.SP_MoaInformationUpdate " + "@requestid = {0}, @authid = {1}, @authfirstname = {2}, @authmiddlename = {3}, @authlastname = {4}, @authdesignation = {5}, @valididtype = {6}, " + "@valididno = {7}, @valididexpdate = {8}, @createddatetime = {9}, @updatedatetime = {10}, @usercreate = {11}, @lastuserupdate = {12}, @isdeleted = {13} ", moa.RequestID, moa.AuthID, moa.AuthFirstName, moa.AuthMiddleName, moa.AuthLastName, moa.AuthDesignation, moa.ValidIDType, moa.ValidIDNumber, moa.ValidIDExpdate, moa.CreatedDateTime, moa.UpdateDeteTime, moa.UserCreate, moa.LastUserUpdate, moa.IsDeleted); } catch (Exception ex) { var temp = "Error - " + ex; await _context.Database.ExecuteSqlCommandAsync("dbo.SP_LogsInformationCreate " + "@logmessage = {0}, @logdatetime = {1} ", temp, DateTime.Now); throw; } await _context.Database.ExecuteSqlCommandAsync("dbo.SP_LogsInformationCreate " + "@logmessage = {0}, @logdatetime = {1} ", "Successfully updated - Moa", DateTime.Now); return(moa); }
public async Task <AgentRequest> CreateAgent(AgentRequest agentRequest) { string generatedRequestID = await CreateRequestID(); int agentID = await CreateAgentID(); int authID = await CreateAgentID(); int masterAgentCode = 0; int submasteragentCode = 0; if (agentRequest.Masteridlist != null) { submasteragentCode = await CreateMasterSubID(); masterAgentCode = Convert.ToInt32(agentRequest.Masteridlist); } else { masterAgentCode = await CreateMasterSubID(); submasteragentCode = 0; } Agent agent = new Agent { AgentID = agentID, BusinessName = agentRequest.BusinessName, City = agentRequest.City, CompanyTIN = agentRequest.Comptin, CorporateName = agentRequest.CorpName, Country = agentRequest.Country, CreatedDateTime = DateTime.Now, CTCNo = agentRequest.CTCNo, DailyDepositLimit = agentRequest.DailyDepLimit, FirstName = agentRequest.FirstName, IsBusiness = agentRequest.IsBusinessName != null?bool.Parse(agentRequest.IsBusinessName) : false, IsCorporate = agentRequest.IsCorpName != null?bool.Parse(agentRequest.IsCorpName) : false, IsMerchCategory = agentRequest.IsMerchcategory != null?bool.Parse(agentRequest.IsMerchcategory) : false, LastName = agentRequest.LastName, LastUserUpdate = agentRequest.User, MasterAgentCodeID = masterAgentCode, MerchantCategory = agentRequest.Merchcategory, MiddleName = agentRequest.MiddleName, PhoneNo = agentRequest.PhoneNo, PostalCode = Convert.ToInt32(agentRequest.PostalCode), RequestID = generatedRequestID, StreetNo = agentRequest.StreetNo, SubAgentCodeID = submasteragentCode, Town = agentRequest.Town, UpdateDeteTime = DateTime.Now, UserCreate = agentRequest.User, Status = "Pending", IsDeleted = false }; Bank bank = new Bank { BankAccountName = agentRequest.Bankaccname, City = agentRequest.BCity, Country = agentRequest.BCountry, CreatedDateTime = DateTime.Now, DepositoryBank = agentRequest.DepBank, LastUserUpdate = agentRequest.User, PostalCode = Convert.ToInt32(agentRequest.BPostalCode), RBOContactNo = agentRequest.RBOContactNo, RBOEmailAdd = agentRequest.RBOEmailAdd, RBOFName = agentRequest.RBOFirstName, RBOLName = agentRequest.RBOLastName, RBOMName = agentRequest.RBOMiddleName, RBOType = agentRequest.RBOType, RequestID = generatedRequestID, StreetNo = agentRequest.BStreetNo, Town = agentRequest.BTown, UpdateDeteTime = DateTime.Now, UserCreate = agentRequest.User, IsDeleted = false }; Contact contact = new Contact { BillingContactNo = agentRequest.CBillContactNo, BillingFirstName = agentRequest.CBillFName, BillingLastName = agentRequest.CBillLName, BillingMiddleName = agentRequest.CBillMName, ContactNo = agentRequest.CContactno, CreatedDateTime = DateTime.Now, Department = agentRequest.CDepartment, Designation = agentRequest.CDesignation, EmailAddress = agentRequest.CEmailAdd, FaxNo = agentRequest.CFaxno, FirstName = agentRequest.CFirstName, LastName = agentRequest.CLastName, LastUserUpdate = agentRequest.User, MiddleName = agentRequest.CMiddleName, RequestID = generatedRequestID, UpdateDeteTime = DateTime.Now, UserCreate = agentRequest.User, IsDeleted = false }; for (int i = 0; i < agentRequest.AgentBranches?.Count(); i++) { AgentBranches agentBranches = new AgentBranches { RequestID = generatedRequestID, AgentBranchName = agentRequest.AgentBranches[i].ABranchName, StreetNo = agentRequest.AgentBranches[i].AStreetNo, Town = agentRequest.AgentBranches[i].ATown, City = agentRequest.AgentBranches[i].ACity, Country = agentRequest.AgentBranches[i].Acountry, PostalCode = Convert.ToInt32(agentRequest.AgentBranches[i].APostalCode), PhoneNo = agentRequest.AgentBranches[i].APhoneNo, UserCreate = agentRequest.User, CreatedDateTime = DateTime.Now, LastUserUpdate = agentRequest.User, UpdateDeteTime = DateTime.Now, IsDeleted = false }; var agentBranchesResponse = await _agentRepository.CreateAgentBranches(agentBranches); } for (int i = 0; i < agentRequest.Terminal?.Count(); i++) { Terminal terminal = new Terminal { RequestID = generatedRequestID, POSTerminalName = agentRequest.Terminal[i].TerminalName, TypeOfPOSTerminal = agentRequest.Terminal[i].TerminalType, CreatedDateTime = DateTime.Now, UserCreate = agentRequest.User, LastUserUpdate = agentRequest.User, UpdateDeteTime = DateTime.Now, IsDeleted = false, TerminalID = agentRequest.Terminal[i].TerminalID, MerchantID = agentRequest.Terminal[i].MerchantID, }; var terminalResponse = await _agentRepository.CreateTerminal(terminal); } for (int i = 0; i < agentRequest.Auth?.Count(); i++) { Moa moa = new Moa { AuthDesignation = agentRequest.Auth[i].AuthDesignation, AuthFirstName = agentRequest.Auth[i].AuthFirstName, AuthID = authID, AuthLastName = agentRequest.Auth[i].AuthLastName, AuthMiddleName = agentRequest.Auth[i].AuthMiddleName, CreatedDateTime = DateTime.Now, LastUserUpdate = agentRequest.User, RequestID = generatedRequestID, UpdateDeteTime = DateTime.Now, UserCreate = agentRequest.User, ValidIDExpdate = agentRequest.Auth[i].ValidIDExpdate, ValidIDNumber = agentRequest.Auth[i].ValidIDNo, ValidIDType = agentRequest.Auth[i].ValidIDType }; var moaResponse = await _agentRepository.CreateMoa(moa); } for (int i = 0; i < agentRequest.BankFeesList?.Count(); i++) { BankFees bankFees = new BankFees { RequestID = generatedRequestID, AgentID = agentID, MerchantID = agentID.ToString(), TransactionType = agentRequest.BankFeesList[i].TransName, ConvenienceFee = agentRequest.BankFeesList[i].ConvFee, Quota = null, CreatedDateTime = DateTime.Now, UserCreate = agentRequest.User, LastUserUpdate = agentRequest.User, UpdateDeteTime = DateTime.Now, IsDeleted = false }; var bankResponse = await _agentRepository.CreateBankFees(bankFees); } var agentResponse = await _agentRepository.CreateAgent(agent, bank, contact); return(agentRequest); }