public async Task <IActionResult> Create(TokenViewModel tokenModel) { var service = await _serviceRepository.Get(tokenModel.ServiceId); var serviceMerchant = await _merchantRepository.Get(tokenModel.MerchantId); var paymentInstrument = await _paymentInstrumentRepository.Select(tokenModel.PaymentInstrumentId); if (service != null && serviceMerchant != null && paymentInstrument != null) { Token token = new Token() { ServiceId = service.Id, MerchantId = serviceMerchant.Id, VProvisionedTokenID = tokenModel.VProvisionedTokenID, TokenStatus = tokenModel.TokenStatus, TokenRequestorID = tokenModel.TokenRequestorID, TokenReferenceID = tokenModel.TokenReferenceID, Last4 = tokenModel.Last4, ExpirationMonth = tokenModel.ExpirationMonth, ExpirationYear = tokenModel.ExpirationYear, AppPrgrmID = tokenModel.AppPrgrmID, TokenAccountNumber = tokenModel.TokenAccountNumber, PaymentInstrumentId = paymentInstrument.Id, Status = tokenModel.Status, Created = DateTime.UtcNow, Updated = null }; await _tokenRepository.Insert(token); } return(RedirectToAction("List")); }
public async Task <IActionResult> Create(ServiceMerchantViewModel serviceMerchantModel) { var service = await _serviceRepository.Get(serviceMerchantModel.ServiceId); var serviceMerchant = await _merchantRepository.Get(serviceMerchantModel.MerchantId); if (service != null && serviceMerchant != null) { ServiceMerchant newServiceMerchant = new ServiceMerchant() { AppId = serviceMerchantModel.AppId, TRId = serviceMerchantModel.TRId, RelationshipName = serviceMerchantModel.RelationshipName, Status = serviceMerchantModel.Status, Created = DateTime.UtcNow, ServiceId = service.Id, MerchantId = serviceMerchant.Id, Updated = null }; await _serviceMerchantRepository.Insert(newServiceMerchant); } return(RedirectToAction("List")); }
public async Task GetTest() { var options = new DbContextOptionsBuilder <JanusContext>() .UseInMemoryDatabase(databaseName: "merchantDb") .Options; using (var context = new JanusContext(options)) { context.Add(new Merchant { Id = 1, Name = "MerchantA", ClientId = "123", ClientSecret = "Megasecret" }); context.SaveChanges(); } using (var newContext = new JanusContext(options)) { var merchantrepo = new MerchantRepository(newContext); var result = await merchantrepo.Get("123"); Assert.AreEqual(1, result.Id); Assert.AreEqual("MerchantA", result.Name); Assert.AreEqual("123", result.ClientId); Assert.AreEqual("Megasecret", result.ClientSecret); } }
public async Task <IActionResult> Edit(int id) { var merchant = await _merchantRepository.Get(id); if (merchant != null) { EditMerchantViewModel editMerchant = new EditMerchantViewModel() { Id = merchant.Id, Name = merchant.Name, OuterId = merchant.OuterId, Status = merchant.Status, Created = merchant.Created }; return(View(editMerchant)); } return(RedirectToAction("Create")); }