public IActionResult Create(AgentViewModel abs) { if (ModelState.IsValid) { Agent model = _mapper.Map <AgentViewModel, Agent>(abs); model.CreatedBy = _admin.FullName; _agentRepository.CreateAgent(model); return(RedirectToAction("index")); } return(View(abs)); }
public IActionResult Create(Agent Agent) { if (Agent.AgencyId > 0) { var agency = _agencyRepository.GetAgencyById(Agent.AgencyId); Agent.CategoryId = agency.CategoryId; } if (ModelState.IsValid) { Agent.CreatedBy = _admin.Fullname; _AgentRepository.CreateAgent(Agent); return(RedirectToAction("index")); } ViewBag.Category = _categoryRepository.GetAllCategories(); ViewBag.Agencies = _agencyRepository.GetAllAgencies(); ViewBag.Cities = _cityRepository.GetAllCities(); return(View(Agent)); }
public Agent CreateAgent(Agent agent) { return(_agentRepository.CreateAgent(agent)); }
public IActionResult CreateUpdateAgent(int?agentId, AgentCreateUpdateDto agentCreateUpdateDto) { Agent agent = null; if (agentCreateUpdateDto == null) { return(BadRequest()); } if (agentId != null) { agent = _agentRepo.GetAgent(agentId); if (agent == null) { return(StatusCode(404)); } } else { agent = new Agent(); } List <Order> newOrders = new List <Order>(); if (agentCreateUpdateDto.Orders != null) { foreach (Order order in agentCreateUpdateDto.Orders) { if (order.Id > 0) { Order existingOrder = _orderRepo.GetOrder(order.Id); newOrders.Add(existingOrder); } else { newOrders.Add(order); } } agent.Orders = newOrders; } List <Customer> newCustomers = new List <Customer>(); if (agentCreateUpdateDto.Customers != null) { foreach (Customer customer in agentCreateUpdateDto.Customers) { if (customer.Id > 0) { Customer existingCustomer = _customerRepo.GetCustomer(customer.Id); newCustomers.Add(existingCustomer); } else { newCustomers.Add(customer); } } agent.Customers = newCustomers; } agent.Name = agentCreateUpdateDto.Name; agent.Commission = agentCreateUpdateDto.Commission; agent.Country = agentCreateUpdateDto.Country; agent.PhoneNumber = agentCreateUpdateDto.PhoneNumber; if (agent.Id > 0 ? _agentRepo.UpdateAgent(agent) : _agentRepo.CreateAgent(agent)) { return(Ok(agent)); } return(StatusCode(500)); }
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); }